home *** CD-ROM | disk | FTP | other *** search
/ Eagles Nest BBS 8 / Eagles_Nest_Mac_Collection_Disc_8.TOAST / Developer Tools⁄Additions / InsideMacDA7 / Manual / Manual
Encoding:
Text File  |  1991-01-27  |  927.0 KB  |  21,977 lines  |  [TEXT/MPS ]

  1. Resource Manager    1
  2. QuickDraw    2
  3. Font Manager    3
  4. Event Manager    4
  5. Window Manager    5
  6. Control Manager    6
  7. Menu Manager    7
  8. Text Edit    8
  9. Dialog Manager    9
  10. Desk Manager    10
  11. Scrap Manager    11
  12. Toolbox Utilities    12
  13. Packages    13
  14. Memory Manager    14
  15. Segment Loader    15
  16. OS Event    16
  17. File Manager    17
  18. Printing Manager    18
  19. Device Manager    19
  20. Disk Manager    20
  21. Serial Manager    22
  22. Appletalk Manager    23
  23. Vertical Retrace Manager    24
  24. OS Utilities    25
  25. List Manager    26
  26. Standard I/O    27
  27. String Manipulation    28
  28. Global equates    30
  29. ADB Manager    31
  30. Cursor Ctl    32
  31. Error Unit    33
  32. SCSI Manager    34
  33. Graf 3D    35
  34. Palette Manager    37
  35. Perf    38
  36. Color Picker    39
  37. SANE    40
  38. Signal    41
  39. Color Manager    42
  40. Control Panel    43
  41. Graphics devices    44
  42. Shutdown Manager    45
  43. Slot Manager    46
  44. Sound Manager    47
  45. Start Manager    48
  46. Task Manager    49
  47. HyperCard XCMDS Info    50
  48. HyperCard Callbacks    51
  49. \ ,129
  50. 129
  51. Resource Manager Definitions.
  52.  
  53. CONST
  54.       resSysHeap    = 64;   { System or application heap? }
  55.       resPurgeable  = 32;   { Purgeable resource? }
  56.       resLocked     = 16;   { Load it in locked? }
  57.       resProtected  = 8;    { Protected? }
  58.       resPreload    = 4;    { Load in on OpenResFile? }
  59.       resChanged    = 2;    { Resource changed? }
  60.  
  61.       mapReadOnly   = 128;  { Resource file read-only }
  62.       mapCompact    = 64;   { Compact resource file }
  63.       mapChanged    = 32;   { Write map out at update }
  64.  
  65.       resNotFound   = - 192; { Resource not found }
  66.       resFNotFound  = - 193; { Resource file not found }
  67.       addResFailed  = - 194; { AddResource failed }
  68.       rmvResFailed  = - 196; { RmveResource failed }
  69.       resAttrErr    = -198;  {attribute does not permit operation}
  70.       mapReadErr    = -199;  {map does not permit operation}
  71.  
  72. Resources in 128 Ko ROM:
  73.  
  74. 'CURS'  1   IBeamCursor
  75. 'CURS'  2   CrossCursor
  76. 'CURS'  3   PlusCursor
  77. 'CURS'  4   WatchCursor
  78. 'DRVR'  2   Printer Driver shell (.PRINT)
  79. 'DRVR'  3   Sound Driver  (.SOUND)
  80. 'DRVR'  4   Disk Driver  (.SONY)
  81. 'DRVR'  9   AppleTalk driver  (.MPP)
  82. 'DRVR'  A   AppleTalk driver  (.ATP)
  83. 'FONT'  0   Name of system font
  84. 'FONT'  C   System font
  85. 'MDEF'  0   Default menu definition procedure
  86. 'PACK'  4   Floating-Point Arithmetic Package
  87. 'PACK'  5   Transcendental Functions Package
  88. 'PACK'  7   Binary-Decimal Conversion Package
  89. 'SERD'  0   Serial Driver
  90. 'WDEF'  0   Default window definition function
  91.  
  92. TYPE
  93.  
  94.       ResType = PACKED ARRAY [1..4] OF CHAR;
  95.  
  96. Assembly language.
  97.  
  98. ; Resource attributes
  99.  
  100. resSysRef       EQU  7   ; reference to system/local reference
  101. resSysHeap      EQU  6   ; In system/in application heap
  102. resPurgeable    EQU  5   ; Purgeable/not purgeable
  103. resLocked       EQU  4   ; Locked/not locked
  104. resProtected    EQU  3   ; Protected/not protected
  105. resPreload      EQU  2   ; Read in at OpenResource?
  106. resChanged      EQU  1   ; Existing resource changed since last update
  107.  
  108. rcbMask         EQU  $FD     ; Must preserve ResChanged over _ResAttrs
  109.  
  110. ; Map attributes
  111.  
  112. mapReadOnly     EQU  7   ; is this file read-only?
  113. mapCompact      EQU  6   ; Is a compact necessary?
  114. mapChanged      EQU  5   ; Is it necessary to write map?
  115.  
  116. ; Resource Manager Globals
  117.  
  118. TopMapHndl      EQU  $A50    ; topmost map in list [handle]
  119. SysMapHndl      EQU  $A54    ; system map [handle]
  120. SysMap          EQU  $A58    ; reference number of system map [word]
  121. CurMap          EQU  $A5A    ; reference number of current map [word]
  122. ResReadOnly     EQU  $A5C    ; Read only flag [word]
  123. ResLoad         EQU  $A5E    ; Auto-load feature [word]
  124. ResErr          EQU  $A60    ; Resource error code [word]
  125. ResErrProc      EQU  $AF2    ; Resource error procedure [pointer]
  126. SysResName      EQU  $AD8    ; Name of system resource file [STRING[19]]
  127.  
  128. ;new Resource Manager stuff
  129.  
  130. RomMapInsert EQU   $B9E         ; (byte) determines if we should link in map
  131. TmpResLoad  EQU    $B9F         ; second byte is temporary ResLoad value.
  132.  
  133. ; the following word values are to be placed into the
  134. ; word located at RomMapInsert
  135.  
  136. MapTrue     EQU    $FFFF        ; link in ROM map with resload true
  137. MapFalse    EQU    $FF00        ; link in ROM map with resload false
  138.  
  139. mCCMask         EQU  $60     ; mapCompact + mapChanged
  140. mChMask         EQU  $20     ; mapChanged
  141. mCoMask         EQU  $40     ; mapCompact
  142. \ ,130
  143. 130
  144. QuickDraw Definitions.
  145.  
  146. CONST
  147.       srcCopy       = 0; { the 16 transfer modes }
  148.       srcOr         = 1;
  149.       srcXor        = 2;
  150.       srcBic        = 3;
  151.       notSrcCopy    = 4;
  152.       notSrcOr      = 5;
  153.       notSrcXor     = 6;
  154.       notSrcBic     = 7;
  155.       patCopy       = 8;
  156.       patOr         = 9;
  157.       patXor        = 10;
  158.       patBic        = 11;
  159.       notPatCopy    = 12;
  160.       notPatOr      = 13;
  161.       notPatXor     = 14;
  162.       notPatBic     = 15;
  163.  
  164.       { QuickDraw color separation constants }
  165.  
  166.       normalBit     = 0; { normal screen mapping }
  167.       inverseBit    = 1; { inverse screen mapping }
  168.       redBit        = 4; { RGB additive mapping }
  169.       greenBit      = 3;
  170.       blueBit       = 2;
  171.       cyanBit       = 8; { CMYBk subtractive mapping }
  172.       magentaBit    = 7;
  173.       yellowBit     = 6;
  174.       blackBit      = 5;
  175.  
  176.       blackColor    = 33; { colors expressed in these mappings }
  177.       whiteColor    = 30;
  178.       redColor      = 205;
  179.       greenColor    = 341;
  180.       blueColor     = 409;
  181.       cyanColor     = 273;
  182.       magentaColor  = 137;
  183.       yellowColor   = 69;
  184.  
  185.       picLParen     = 0;   { standard picture comments }
  186.       picRParen     = 1;
  187.  
  188.       iBeamCursor   = 1; {text selection cursor}
  189.       crossCursor   = 2; {for drawing graphics}
  190.       plusCursor    = 3; {for structured selection}
  191.       watchCursor   = 4; {for indicating a long delay}
  192.      { Arithmetic transfer modes }
  193.       blend    = 32;
  194.       addPin   = 33;
  195.       addOver  = 34;
  196.       subPin   = 35;
  197.       adMax    = 37;
  198.       subOver  = 38;
  199.       adMin    = 39;
  200.      { Transparent mode constant }
  201.         transparent  = 36;
  202.      { Text mask constant }
  203.          mask    = 64;
  204.      { Highlight constants }
  205.        hilite    = 50;
  206.        pHiliteBit    = 0;    {this is the correct value for use when }
  207.                              { calling the BitClear trap. BClr must use }
  208.                              { the assembly language equate hiliteBit}
  209.  
  210. TYPE
  211.       QDByte = SignedByte;
  212.       QDPtr = Ptr; { blind pointer }
  213.       QDHandle = Handle; { blind handle }
  214.       Pattern = PACKED ARRAY [0..7] OF 0..255;
  215.       Bits16 = ARRAY [0..15] OF INTEGER;
  216.       VHSelect = (v, h);
  217.       GrafVerb = (frame, paint, erase, invert, fill);
  218.       StyleItem = (bold, italic, underline, outline, shadow, condense,
  219.                     extend);
  220.       Style = SET OF StyleItem;
  221.  
  222.       FontInfo = RECORD
  223.                    ascent: INTEGER;
  224.                    descent: INTEGER;
  225.                    widMax: INTEGER;
  226.                    leading: INTEGER;
  227.                  END;
  228.  
  229.       Point = RECORD
  230.                 CASE INTEGER OF
  231.  
  232.                   0:
  233.                     (v: INTEGER;
  234.                      h: INTEGER);
  235.  
  236.                   1:
  237.                     (vh: ARRAY [VHSelect] OF INTEGER);
  238.  
  239.               END;
  240.  
  241.       Rect = RECORD
  242.                CASE INTEGER OF
  243.  
  244.                  0:
  245.                    (top: INTEGER;
  246.                     left: INTEGER;
  247.                     bottom: INTEGER;
  248.                     right: INTEGER);
  249.  
  250.                  1:
  251.                    (topLeft: Point;
  252.                     botRight: Point);
  253.              END;
  254.  
  255.       BitMap = RECORD
  256.                  baseAddr: Ptr;
  257.                  rowBytes: INTEGER;
  258.                  bounds: Rect;
  259.                END;
  260.  
  261.       Cursor = RECORD
  262.                  data: Bits16;
  263.                  mask: Bits16;
  264.                  hotSpot: Point;
  265.                END;
  266.  
  267.       PenState = RECORD
  268.                    pnLoc: Point;
  269.                    pnSize: Point;
  270.                    pnMode: INTEGER;
  271.                    pnPat: Pattern;
  272.                  END;
  273.  
  274.       PolyHandle = ^PolyPtr;
  275.       PolyPtr = ^Polygon;
  276.       Polygon = RECORD
  277.                   polySize: INTEGER;
  278.                   polyBBox: Rect;
  279.                   polyPoints: ARRAY [0..0] OF Point;
  280.                 END;
  281.  
  282.       RgnHandle = ^RgnPtr;
  283.       RgnPtr = ^Region;
  284.       Region = RECORD
  285.                  rgnSize: INTEGER; { rgnSize = 10 for rectangular }
  286.                  rgnBBox: Rect;
  287.                         { plus more data if not rectangular }
  288.                END;
  289.  
  290.       PicHandle = ^PicPtr;
  291.       PicPtr = ^Picture;
  292.       Picture = RECORD
  293.                   picSize: INTEGER;
  294.                   picFrame: Rect;
  295.                           { plus byte codes for picture content }
  296.                 END;
  297.  
  298.       QDProcsPtr = ^QDProcs;
  299.       QDProcs = RECORD
  300.                   textProc: Ptr;
  301.                   lineProc: Ptr;
  302.                   rectProc: Ptr;
  303.                   rRectProc: Ptr;
  304.                   ovalProc: Ptr;
  305.                   arcProc: Ptr;
  306.                   polyProc: Ptr;
  307.                   rgnProc: Ptr;
  308.                   bitsProc: Ptr;
  309.                   commentProc: Ptr;
  310.                   txMeasProc: Ptr;
  311.                   getPicProc: Ptr;
  312.                   putPicProc: Ptr;
  313.                 END;
  314.  
  315.       GrafPtr = ^GrafPort;
  316.       GrafPort = RECORD
  317.                    device: INTEGER;
  318.                    portBits: BitMap;
  319.                    portRect: Rect;
  320.                    visRgn: RgnHandle;
  321.                    clipRgn: RgnHandle;
  322.                    bkPat: Pattern;
  323.                    fillPat: Pattern;
  324.                    pnLoc: Point;
  325.                    pnSize: Point;
  326.                    pnMode: INTEGER;
  327.                    pnPat: Pattern;
  328.                    pnVis: INTEGER;
  329.                    txFont: INTEGER;
  330.                    txFace: Style;
  331.                    txMode: INTEGER;
  332.                    txSize: INTEGER;
  333.                    spExtra: Fixed;
  334.                    fgColor: LongInt;
  335.                    bkColor: LongInt;
  336.                    colrBit: INTEGER;
  337.                    patStretch: INTEGER;
  338.                    picSave: Handle;
  339.                    rgnSave: Handle;
  340.                    polySave: Handle;
  341.                    grafProcs: QDProcsPtr;
  342.                  END;
  343.  
  344.    RGBColor = RECORD
  345.       red:   INTEGER;   {red component}
  346.       green: INTEGER;   {green component}
  347.       blue:  INTEGER    {blue component}
  348.    END;
  349.  
  350.    ColorSpec = RECORD
  351.                  value: INTEGER;    {index or other value}
  352.                  rgb:   RGBColor    {true color}
  353.                END;
  354.    cSpecArray : ARRAY [0..0] of ColorSpec;
  355.  
  356.    CTabHandle = ^CTabPtr;
  357.    CTabPtr    = ^ColorTable;
  358.    ColorTable = RECORD
  359.      ctSeed:    LONGINT;    {unique identifier from table}
  360.      ctFlags: INTEGER;      {high bit is 1 for device, 0 for pixMap}
  361.      ctSize:    INTEGER;    {number of entries -1 in ctTable}
  362.      ctTable: cSpecArray
  363.    END;
  364.  
  365.    CGrafPtr  = ^CGrafPort;
  366.    CGrafPort = RECORD
  367.          device: INTEGER;           {device ID for font selection}
  368.          portPixMap: PixMapHandle;  {port's pixel map}
  369.          portVersion: INTEGER;      {highest 2 bits always set}
  370.          grafVars: Handle;          {handle to more fields}
  371.          chExtra: INTEGER;          {extra characters placed on the end}
  372.                                     { of a string}
  373.          pnLocHFrac: INTEGER;       {pen fraction}
  374.          portRect: Rect;            {port rectangle}
  375.          visRgn: RgnHandle;         {visible region}
  376.          clipRgn: RgnHandle;        {clipping region}
  377.          bkPixPat: PixPatHandle;    {background pattern}
  378.          rgbFgColor: RGBColor;      {requested foreground color}
  379.          rgbBkColor: RGBColor;      {requested background color}
  380.          pnLoc: Point;              {pen location}
  381.          pnSize: Point;             {pen size}
  382.          pnMode: INTEGER;           {pen transfer mode}
  383.          pnPixPat: PixPatHandle;    {pen pattern}
  384.          fillPixPat: PixPatHandle;  {fill pattern}
  385.          pnVis: INTEGER;            {pen visibility}
  386.          txFont: INTEGER;           {font number for text}
  387.          txFace: Style;             {text's character style}
  388.          txMode: INTEGER;           {text's transfer mode}
  389.          txSize: INTEGER;           {font size for text}
  390.          spExtra: Fixed;            {extra space}
  391.          fgColor: LONGINT;          {actual foreground color}
  392.          bkColor: LONGINT;          {actual background color}
  393.          colrBit: INTEGER;          {plane being drawn}
  394.          patStretch: INTEGER;       {used internally}
  395.          picSave: Handle;           {picture being saved}
  396.          rgnSave: Handle;           {region being saved}
  397.          polySave: Handle;          {polygon being saved}
  398.          grafProcs: CQDProcsPtr     {low-level drawing routines}
  399.        END;
  400.  
  401.     GrafVars = RECORD
  402.            rgbOpColor:  RGBColor;   {color for addPin, subPin, and blend}
  403.            rgbHiliteColor: RGBColor; {color for hiliting}
  404.            pmFgColor: Handle;       {palette handle for foreground color}
  405.            pmFgIndex: INTEGER;      {index value for foreground}
  406.            pmBkColor: Handle;       {palette handle for background color}
  407.            pmBkIndex: INTEGER;      {index value for background}
  408.            pmFlags: INTEGER;        {flags for Palette Manager}
  409.          END;
  410.  
  411.   PixMapHandle = ^PixMapPtr;
  412.   PixMapPtr    = ^PixMap;
  413.   PixMap       = RECORD
  414.         baseAddr: Ptr;      {pointer to pixMap data}
  415.         rowBytes: INTEGER;  {offset to next row}
  416.         bounds: Rect;       {boundary rectangle}
  417.         pmVersion: INTEGER; {color QuickDraw version number}
  418.         packType: INTEGER;  {packing format}
  419.         packSize: LONGINT;  {size of data in packed state}
  420.         hRes: Fixed;        {horizontal resolution}
  421.         vRes: Fixed;        {vertical resolution}
  422.         pixelType: INTEGER; {format of pixel image}
  423.         pixelSize: INTEGER; {physical bits per pixel}
  424.         cmpCount: INTEGER;  {logical components per pixel}
  425.         cmpSize: INTEGER;   {logical bits per component}
  426.         planeBytes: LONGINT;{offset to next plane}
  427.         pmTable: CTabHandle;{absolute colors for this image}
  428.         pmReserved: LONGINT {reserved for future expansion}
  429.     END;
  430.  
  431.   PixPatHandle = ^PixPatPtr;
  432.   PixPatPtr    = ^PixPat;
  433.   PixPat       = RECORD
  434.         patType: INTEGER;   {pattern type}
  435.         patMap: PixMapHandle;{pattern characteristics}
  436.         patData: Handle;    {pixel image defining pattern}
  437.         patXData: Handle;   {expanded pixel image}
  438.         patXValid: INTEGER; {flags for expanded pattern data}
  439.         patXMap: Handle;    {handle to expanded pattern data}
  440.         pat1Data: Pattern;  {old-style pattern/RGB color}
  441.       END;
  442.  
  443.    CCrsrHandle  = ^CCrsrPtr;
  444.    CCrsrPtr = ^CCrsr;
  445.    CCrsr    = RECORD
  446.         crsrType: INTEGER;      {type of cursor}
  447.         crsrMap: PixMapHandle;  {the cursor's pixMap}
  448.         crsrData: Handle;       {cursor's data}
  449.         crsrXData: Handle;      {expanded cursor data}
  450.         crsrXValid: INTEGER;    {depth of expanded data}
  451.         crsrXHandle: Handle;    {reserved for future use}
  452.         crsr1Data: Bits16;      {one-bit cursor}
  453.         crsrMask: Bits16;       {cursor's mask}
  454.         crsrHotSpot: Point;     {cursor's hotspot}
  455.         crsrXTable: LONGINT;    {private}
  456.         crsrID: LONGINT;        {ctSeed for expanded cursor}
  457.       END;
  458.  
  459.    CIconHandle  = ^CIconPtr;
  460.    CIconPtr = ^CIcon;
  461.    CIcon    = RECORD
  462.         iconPMap:   PixMap; {the icon's pixMap}
  463.         iconMask:   BitMap; {the icon's mask bitMap}
  464.         iconBMap:   BitMap; {the icon's bitMap}
  465.         iconData:   Handle; {the icon's data}
  466.         iconMaskData: ARRAY[0..0] OF INTEGER;   {icon's}
  467.                                                 { mask and bitMap data}
  468.        END;
  469.  
  470.     MatchRec = RECORD
  471.       red: INTEGER;     {red component}
  472.       green: INTEGER;   {green component}
  473.       blue: INTEGER;    {blue component}
  474.       matchData: LONGINT;
  475.     END;
  476.  
  477.    CQDProcsPtr  = ^CQDProcs
  478.    CQDProcs = RECORD
  479.         textProc:       Ptr;
  480.         lineProc:       Ptr;
  481.         rectProc:       Ptr;
  482.         rRectProc:      Ptr;
  483.         ovalProc:       Ptr;
  484.         arcProc:        Ptr;
  485.         polyProc:       Ptr;
  486.         rgnProc:        Ptr;
  487.         bitsProc:       Ptr;
  488.         commentProc:    Ptr;
  489.         txMeasProc:     Ptr;
  490.         getPicProc:     Ptr;
  491.         putPicProc:     Ptr;
  492.         opcodeProc:     Ptr;    {fields added to QDProcs}
  493.         newProc1:       Ptr;    {reserved for future use}
  494.         newProc2:       Ptr;    {reserved for future use}
  495.         newProc3:       Ptr;    {reserved for future use}
  496.         newProc4:       Ptr;    {reserved for future use}
  497.         newProc5:       Ptr;    {reserved for future use}
  498.         newProc6:       Ptr;    {reserved for future use}
  499.       END;
  500.  
  501.  
  502.     VAR
  503.       thePort: GrafPtr;
  504.       white: Pattern;
  505.       black: Pattern;
  506.       gray: Pattern;
  507.       ltGray: Pattern;
  508.       dkGray: Pattern;
  509.       arrow: Cursor;
  510.       screenBits: BitMap;
  511.       randSeed: LongInt;
  512.  
  513. Assembly language.
  514.  
  515. ; GrafPort Structure
  516.  
  517. device          EQU  $0      ; device code [word]
  518. portBits        EQU  $2      ; port's bitmap [bitmap]
  519. portBounds      EQU  $8      ; bounding box of bitmap [rect]
  520. portRect        EQU  $10     ; port's rectangle [rect]
  521. visRgn          EQU  $18     ; visible region [handle]
  522. clipRgn         EQU  $1C     ; clipping region [handle]
  523. bkPat           EQU  $20     ; background [pattern]
  524. fillPat         EQU  $28     ; fill [pattern]
  525. pnLoc           EQU  $30     ; pen location [point]
  526. pnSize          EQU  $34     ; pen size [point]
  527. pnMode          EQU  $38     ; pen mode [word]
  528. pnPat           EQU  $3A     ; pen [pattern]
  529. pnVis           EQU  $42     ; pen visible [word]
  530. txFont          EQU  $44     ; text font [word]
  531. txFace          EQU  $46     ; text face [word]
  532. txMode          EQU  $48     ; text mode [word]
  533. txSize          EQU  $4A     ; text size [word]
  534. spExtra         EQU  $4C     ; space extra [fixed]
  535. fgColor         EQU  $50     ; foreground color mask [long]
  536. bkColor         EQU  $54     ; background color mask [long]
  537. colrBit         EQU  $58     ; color bit [word]
  538. patStretch      EQU  $5A     ; pattern stretch [word]
  539. picSave         EQU  $5C     ; picture being saved [handle]
  540. rgnSave         EQU  $60     ; region being saved [handle]
  541. polySave        EQU  $64     ; polygon being saved [handle]
  542. grafProcs       EQU  $68     ; QDProcs array [pointer]
  543. portRec         EQU  $6C     ; size of grafport
  544.  
  545.  
  546. ; QuickDraw Global Variables
  547.  
  548.  
  549. GrafGlobals     EQU  0   ; A5 offset to globptr
  550.  
  551. thePort         EQU     0               ;GrafPtr
  552. white           EQU     thePort-8       ;Pattern
  553. black           EQU     white-8         ;Pattern
  554. gray            EQU     black-8         ;Pattern
  555. ltGray          EQU     gray-8          ;Pattern
  556. dkGray          EQU     ltGray-8        ;Pattern
  557. arrow           EQU     dkGray-68       ;Cursor
  558. screenBits      EQU     arrow-14        ;BitMap
  559. randSeed        EQU     screenBits-4    ;LONGINT
  560.  
  561. ; RGBColor structure
  562.  
  563. red             EQU     $0          ;red channel intensity  [short]
  564. green           EQU     $2          ;green channel intensity[short]
  565. blue            EQU     $4          ;blue channel intensity [short]
  566. rgbColor        EQU     $6          ;size of record
  567.  
  568. ; ColorSpec structure
  569.  
  570. value           EQU     $0          ;value field    [short]
  571. rgb             EQU     $2          ;rgb values     [rgbColor]
  572. colorSpecSize   EQU     $8          ;size of record
  573.  
  574. procLstSiz      EQU     8           ; size of search/comp Proc
  575. protect         EQU     7           ; protect bit is bit #8
  576. reserveBit      EQU     6           ; reserve bit is bit #7
  577.  
  578. ; CProcRec structure                                                    <C96/29Jul86>DAF
  579.  
  580. nxtComp         EQU     $0          ;link to next proc  [pointer]
  581. compProc        EQU     $4          ;pointer to routine [pointer]
  582.  
  583. invalColReq     EQU     -1          ; invalid color table request       <C621/13Jan87> DAF
  584.  
  585. ;  Equates for resource ID's
  586.  
  587. defQDColors     EQU     127         ; resource ID of clut for default QDColors
  588.  
  589.  
  590.  
  591. ;  PixMap field offsets
  592. ;
  593.  
  594. pmBaseAddr      EQU     $00             ; [long]
  595. pmNewFlag       EQU     $04             ; [1 bit]   upper bit of rowbytes is flag
  596. pmRowBytes      EQU     $08             ; [word]
  597. pmBounds        EQU     $0A             ; [rect]
  598. pmVersion       EQU     $12             ; [word]    pixMap version number
  599. pmPackType      EQU     $14             ; [word]    defines packing format
  600. pmPackSize      EQU     $16             ; [long]    size of pixel data
  601. pmHRes          EQU     $1A             ; [fixed]   h. resolution (ppi)
  602. pmVRes          EQU     $1E             ; [fixed]   v. resolution (ppi)
  603. pmPixelType     EQU     $22             ; [word]    defines pixel type
  604. pmPixelSize     EQU     $24             ; [word]    # bits in pixel
  605. pmCmpCount      EQU     $26             ; [word]    # components in pixel
  606. pmCmpSize       EQU     $28             ; [word]    # bits per field
  607. pmPlaneBytes    EQU     $2A             ; [long]    offset to next plane
  608. pmTable         EQU     $2E             ; [long]    color map
  609. pmReserved      EQU     $32             ; [long]    MUST BE 0
  610.  
  611. pmRec           EQU     $36             ; size of pixelMap record
  612.  
  613. ;  PixPat field offsets
  614. ;
  615.  
  616. patType         EQU     0               ; [word] type of pattern
  617. patMap          EQU     2               ; [long] handle to pixmap
  618. patData         EQU     6               ; [long] handle to data
  619. patXData        EQU     10              ; [long] handle to expanded pattern data
  620. patXValid       EQU     14              ; [word] flags whether expanded pattern valid
  621. patXMap         EQU     16              ; [long] handle to expanded pattern data
  622. pat1Data        EQU     20              ; [8 bytes] old-style pattern/RGB color
  623.  
  624. ppRec           EQU     28              ; size of pixPat record
  625.  
  626. ;------------------
  627. ;  fields within patXMap
  628.  
  629. patXRow         EQU     0               ; [word] rowbytes of expanded pattern
  630. patXHMask       EQU     2               ; [word] horizontal mask
  631. patXVMask       EQU     4               ; [word] vertical mask
  632. LastCTable      EQU     6               ; [long] seed value for last color table
  633. LastOfst        EQU     10              ; [word] last global-local offset
  634. LastInvert      EQU     12              ; [long] last invert value
  635. LastAlign       EQU     16              ; [long] last horizontal align
  636. LastStretch     EQU     20              ; [word] last stretch
  637.  
  638. ppXInfo         EQU     22              ; size of expanded data
  639.  
  640. ;  Pattern types
  641. ;
  642.  
  643. oldPat          EQU     0               ; foreground/background pattern
  644. newPat          EQU     1               ; self-contained color pattern
  645. ditherPat       EQU     2               ; rgb value to be dithered
  646.  
  647. oldCrsrPat      EQU     $8000           ; old-style cursor
  648. cCrsrPat        EQU     $8001           ; new-style cursor
  649.  
  650. ;  GDevice field offsets
  651. ;
  652.  
  653. gdRefNum        EQU     $00  ; [word] unitNum of driver
  654. gdID            EQU     $02  ; [word] client ID for search procs
  655. gdType          EQU     $04  ; [word] fixed/CLUT/direct
  656. gdITable        EQU     $06  ; [long] handle to inverse table
  657. gdResPref       EQU     $0A  ; [word] preferred resolution for inverse tables
  658. gdSearchProc    EQU     $0C  ; [long] search proc (list?) pointer
  659. gdCompProc      EQU     $10  ; [long] complement proc (list?) pointer
  660. gdFlags         EQU     $14  ; [word] grafDevice flags word
  661. gdPMap          EQU     $16  ; [long] handle to pixMap describing device
  662. gdRefCon        EQU     $1A  ; [long] reference value
  663. gdNextGD        EQU     $1E  ; [long] handle of next gDevice
  664. gdRect          EQU     $22  ; [rect] device's bounds in global coordinates
  665. gdMode          EQU     $2A  ; [long] device's current mode
  666. gdCCBytes       EQU     $2E  ; [word] depth of expanded cursor data
  667. gdCCDepth       EQU     $30  ; [word] depth of expanded cursor data
  668. gdCCXData       EQU     $32  ; [long] handle to cursor's expanded data
  669. gdCCXMask       EQU     $36  ; [long] handle to cursor's expanded mask
  670. gdReserved      EQU     $3A  ; [long] MUST BE 0
  671.  
  672. gdRec           EQU     $3E  ; size of GrafDevice record
  673.  
  674. ; VALUES FOR GDType
  675.  
  676. clutType        EQU     0    ; 0 if lookup table
  677. fixedType       EQU     1    ; 1 if fixed table
  678. directType      EQU     2    ; 2 if direct values
  679.  
  680. ;  BIT ASSIGNMENTS FOR GDFlags
  681.  
  682. gdDevType       EQU     0    ; 0 = monochrome; 1 = color
  683. ramInit         EQU     10   ; 1 if initialized from 'scrn' resource
  684. mainScrn        EQU     11   ; 1 if main screen
  685. allInit         EQU     12   ; 1 if all devices initialized
  686. screenDevice    EQU     13   ; 1 if screen device [not used]
  687. noDriver        EQU     14   ; 1 if no driver for this GDevice
  688. scrnActive      EQU     15   ; 1 if in use
  689.  
  690. ; inverse Table structure
  691. ITabSeed        EQU     $0   ;[long] ID of owning color table
  692. ITabRes         EQU     $4   ;[word] client ID
  693. ITTable         EQU     $6   ;table of indices starts here
  694. \ ,131
  695. 131
  696. Font Manager Definitions.
  697.  
  698. CONST
  699.  
  700.       commandMark   = $11;
  701.       checkMark     = $12;
  702.       diamondMark   = $13;
  703.       appleMark     = $14;
  704.  
  705.       systemFont    = 0;
  706.       applFont      = 1;
  707.       newYork       = 2;
  708.       geneva        = 3;
  709.       monaco        = 4;
  710.       venice        = 5;
  711.       london        = 6;
  712.       athens        = 7;
  713.       sanFran       = 8;
  714.       toronto       = 9;
  715.       cairo         = 11;
  716.       losAngeles    = 12;
  717.       times         = 20;
  718.       helvetica     = 21;
  719.       courier       = 22;
  720.       symbol        = 23;
  721.       mobile        = 24;
  722.  
  723.       propFont      = $9000;
  724.       prpFntH       = $9001;
  725.       prpFntW       = $9002;
  726.       prpFntHW      = $9003;
  727.  
  728.       fixedFont     = $B000;
  729.       fxdFntH       = $B001;
  730.       fxdFntW       = $B002;
  731.       fxdFntHW      = $B003;
  732.  
  733.       fontWid       = $ACB0;
  734.  
  735. TYPE
  736.  
  737.       FMInput = PACKED RECORD
  738.                   family: INTEGER;
  739.                   size: INTEGER;
  740.                   face: Style;
  741.                   needBits: BOOLEAN;
  742.                   device: INTEGER;
  743.                   numer: Point;
  744.                   denom: Point;
  745.                 END;
  746.  
  747.       FMOutPtr = ^FMOutPut;
  748.  
  749.       FMOutPut = PACKED RECORD
  750.                    errNum: INTEGER;
  751.                    fontHandle: Handle;
  752.                    bold: Byte;
  753.                    italic: Byte;
  754.                    ulOffset: Byte;
  755.                    ulShadow: Byte;
  756.                    ulThick: Byte;
  757.                    shadow: Byte;
  758.                    extra: SignedByte;
  759.                    ascent: Byte;
  760.                    descent: Byte;
  761.                    widMax: Byte;
  762.                    leading: SignedByte;
  763.                    unused: Byte;
  764.                    numer: Point;
  765.                    denom: Point;
  766.                  END;
  767.  
  768.       FontRec = RECORD
  769.                   fontType: INTEGER;    { font type }
  770.                   firstChar: INTEGER;   { ASCII code of first character }
  771.                   lastChar: INTEGER;    { ASCII code of last character }
  772.                   widMax: INTEGER;      { maximum character width }
  773.                   kernMax: INTEGER;     { negative of maximum character kern }
  774.                   nDescent: INTEGER;    { negative of descent }
  775.                   fRectWidth: INTEGER;  { width of font rectangle }
  776.                   fRectHeight: INTEGER; { height of font rectangle }
  777.                   oWTLoc: INTEGER;      { offset to offset/width table }
  778.                   ascent: INTEGER;      { ascent }
  779.                   descent: INTEGER;     { descent }
  780.                   leading: INTEGER;     { leading }
  781.                   rowWords: INTEGER;    { row width of bit image / 2 }
  782.                 { bitImage:    ARRAY[1..rowWords,1..fRectHeight]
  783.                                     OF INTEGER;
  784.                   locTable:    ARRAY[firstChar..lastChar+2]
  785.                                     OF INTEGER;
  786.                   owTable:    ARRAY[firstChar..lastChar+2]
  787.                                     OF INTEGER;
  788.                   widthTable: ARRAY[firstChar..lastChar+2]
  789.                                     OF INTEGER;
  790.                   heightTable: ARRAY[firstChar..lastChar+2]
  791.                                     OF INTEGER; }
  792.                 END;
  793.  
  794.       {new 128K ROM}
  795.  
  796.       FMetricRec = RECORD
  797.                      ascent: Fixed;     {base line to top}
  798.                      descent: Fixed;    {base line to bottom}
  799.                      leading: Fixed;    {leading between lines}
  800.                      widMax: Fixed;     {maximum character width}
  801.                      wTabHandle: Fixed; {handle to font width table}
  802.                    END;
  803.  
  804.       WidTable = RECORD
  805.                    numWidths: INTEGER; {number of entries - 1}
  806.                             {widList: ARRAY[1..numWidths] of WidEntry}
  807.                  END;
  808.  
  809.       WidEntry = RECORD
  810.                    widStyle: INTEGER; {style entry applies to}
  811.                                       {widRec: ARRAY[firstChar..lastChar]
  812.                                         of INTEGER}
  813.                  END;
  814.  
  815.       AsscEntry = RECORD
  816.                     fontSize: INTEGER;
  817.                     fontStyle: INTEGER;
  818.                     fontID: INTEGER; {font resource ID}
  819.                   END;
  820.  
  821.       FontAssoc = RECORD
  822.                     numAssoc: INTEGER; {number of entries - 1}
  823.                             {asscTable: ARRAY[1..numAssoc] OF AsscEntry}
  824.                   END;
  825.  
  826.       StyleTable = RECORD
  827.                      fontClass: INTEGER;
  828.                      offset: LongInt;
  829.                      reserved: LongInt;
  830.                      indexes: ARRAY [0..47] OF Byte;
  831.                    END;
  832.  
  833.       NameTable = RECORD
  834.                     stringCount: INTEGER;
  835.                     baseFontName: STR255;
  836.                                 {strings: ARRAY[2..stringCount]  OF STRING}
  837.                                 {the lengths of the strings are arbitrary}
  838.                   END;
  839.  
  840.       KernPair = RECORD
  841.                    kernFirst: CHAR; {1st character of kerned pair}
  842.                    kernSecond: CHAR; {2nd character of kerned pair}
  843.                    kernWidth: INTEGER; {kerning in 1pt fixed format}
  844.                  END;
  845.  
  846.       KernEntry = RECORD
  847.                     kernLength: INTEGER; {length of this entry}
  848.                     kernStyle: INTEGER; {style the entry applies to}
  849.                              {kernRec: ARRAY[1..(kernLength/4)-1] OF KernPair}
  850.                   END;
  851.  
  852.       KernTable = RECORD
  853.                     numKerns: INTEGER; {number of kerning entries}
  854.                             {kernList: ARRAY[1..numKerns] OF KernEntry}
  855.                   END;
  856.  
  857.       WidthTable = PACKED RECORD
  858.                      tabData: ARRAY [1..256] OF Fixed; {character widths}
  859.                      tabFont: Handle; {font record used to build table}
  860.                      sExtra: LongInt; {space extra used for table}
  861.                      Style: LongInt; {extra due to style}
  862.                      fID: INTEGER; {font family ID}
  863.                      fSize: INTEGER; {font size request}
  864.                      face: INTEGER; {style (face) request}
  865.                      device: INTEGER; {device requested}
  866.                      vInScale: Fixed; {scale factors requested}
  867.                      hInScale: Fixed; {scale factors requested}
  868.                      aFID: INTEGER; {actual font family ID for table}
  869.                      fHand: Handle; {family record used to build up table}
  870.                      usedFam: BOOLEAN; {used fixed point family widths}
  871.                      aFace: Byte; {actual face produced}
  872.                      vOutput: INTEGER; {vertical scale output value}
  873.                      hOutput: INTEGER; {horizontal scale output value}
  874.                      vFactor: INTEGER; {vertical scale output value}
  875.                      hFactor: INTEGER; {horizontal scale output value}
  876.                      aSize: INTEGER; {actual size of actual font used}
  877.                      tabSize: INTEGER; {total size of table}
  878.                    END;
  879.  
  880.       FamRec = RECORD
  881.                  ffFlags: INTEGER; {flags for family}
  882.                  ffFamID: INTEGER; {family ID number}
  883.                  ffFirstChar: INTEGER; {ASCII code of 1st character}
  884.                  ffLastChar: INTEGER; {ASCII code of last character}
  885.                  ffAscent: INTEGER; {maximum ascent for 1pt font}
  886.                  ffDescent: INTEGER; {maximum descent for 1pt font}
  887.                  ffLeading: INTEGER; {maximum leading for 1pt font}
  888.                  ffWidMax: INTEGER; {maximum widMax for 1pt font}
  889.                  ffWTabOff: LongInt; {offset to width table}
  890.                  ffKernOff: LongInt; {offset to kerning table}
  891.                  ffStylOff: LongInt; {offset to style mapping table}
  892.                  ffProperty: ARRAY [1..9] OF INTEGER; {style property info}
  893.                  ffIntl: ARRAY [1..2] OF INTEGER; {for international use}
  894.                  ffVersion: INTEGER; {version number}
  895.                           {ffAssoc:    FontAssoc;} {font association table}
  896.                           {ffWidthTab: WidTable;} {width table}
  897.                           {ffStyTab:   StyleTable;} {style mapping table}
  898.                           {ffKernTab:  KernTable;} {kerning table}
  899.                END;
  900.  
  901. Assembly language.
  902.  
  903.  
  904. ; Standard font ID's
  905.  
  906. sysFont         EQU  0   ; system font ID
  907. applFont        EQU  1   ; application font ID
  908.  
  909. newYork         EQU  2   ; standard release fonts
  910. geneva          EQU  3
  911. monaco          EQU  4
  912. venice          EQU  5
  913. london          EQU  6
  914. athens          EQU  7
  915. sanFran         EQU  8
  916. toronto         EQU  9
  917. cairo           EQU  11
  918. losAngeles      EQU  12
  919. times           EQU  20
  920. helvetica       EQU  21
  921. courier         EQU  22
  922. symbol          EQU  23
  923. mobile          EQU  24
  924.  
  925. ; Font Manager Globals
  926.  
  927. ApFontID        EQU  $984    ; resource ID of application font [word]
  928. FMDefaultSize   EQU  $987    ; default size [byte]
  929. CurFMInput      EQU  $988    ; quickdraw FMInput Record [pointer]
  930. FMgrOutRec      EQU  $998    ; quickdraw FontOutput Record [pointer]
  931. FScaleDisable   EQU  $A63    ; disable font scaling? [byte]
  932.  
  933. ;new FONT manager stuff
  934.  
  935. WidthListHand   EQU    $8E4         ; list of extra width tables, or nil.
  936. WidthPtr        EQU    $B10         ; (long) Font Mgr global
  937. WidthTabHandle  EQU    $B2A         ; Font width table handle for measure
  938. LastSPExtra     EQU    $B4C         ; (long) most recent value of space extra
  939. SysFontFam      EQU    $BA6         ; (word) System font family ID or zero
  940. SysFontSize     EQU    $BA8         ; (word) System font size (or zero for 12 pt)
  941. FDevDisable     EQU    $BB3         ; (byte) $FF to disable device-defined style extra
  942. LastFOND        EQU    $BC2         ; (long) handle of last font def record
  943. FONDID          EQU    $BC6         ; (word) ID of last font def record
  944. FractEnable     EQU    $BF4         ; (byte) flag for fractional font widths
  945. UsedFWidths     EQU    $BF5         ; (byte) flag saying if we used fract widths
  946. FScaleHFact     EQU    $BF6         ; (long) horz. font scale factor
  947. FScaleVFact     EQU    $BFA         ; (long) vertical font scale factor
  948.  
  949. ; Font header values
  950.  
  951. propFont        EQU  $9000   ; proportional font type
  952. prpFntH         EQU  $9001   ; with height table
  953. prpFntW         EQU  $9002   ; with width table
  954. prpFntHW        EQU  $9003   ; with height & width table
  955.  
  956. fixedFont       EQU  $B000   ; fixed-pitch font type
  957. fxdFntH         EQU  $B001   ; with height table
  958. fxdFntW         EQU  $B002   ; with width table
  959. fxdFntHW        EQU  $B003   ; with height & width table
  960.  
  961. fontWid         EQU  $ACB0   ; width-only font type
  962.  
  963. ; control/status codes for linkage w/font manager
  964.  
  965. fMgrCtl1        EQU  8   ; printer drivers
  966.  
  967. ; Font Header Data Record
  968.  
  969. fFontType       EQU  0   ; font type [word]
  970. fFirstChar      EQU  2   ; ASCII code of first char [word]
  971. fLastChar       EQU  4   ; ASCII code of last char [word]
  972. fWidMax         EQU  6   ; maximum width of any char in pixels [word]
  973. fKernMax        EQU  8   ; Negative of maximum character kern [word]
  974. fNDescent       EQU  10  ; negative of descent [word]
  975. fFRectWidth     EQU  12  ; width of font rectangle [word]
  976. fFRectHeight    EQU  14  ; height of font rectangle [word]
  977. fOWTLoc         EQU  16  ; offset to offset/width table [word]
  978. fAscent         EQU  18  ; ascent above baseline in pixels [word]
  979. fDescent        EQU  20  ; descent below baseline in pixels [word]
  980. fLeading        EQU  22  ; space between lines in pixels [word]
  981. fRowWords       EQU  24  ; row width of bit image / 2 [word]
  982.  
  983. ; Font Manager Input Record (CurFMInput)
  984.  
  985. fmInFamily      EQU  0   ; family [word]
  986. fmInSize        EQU  2   ; size [word]
  987. fmInFace        EQU  4   ; face [word]
  988. fmInNeedBits    EQU  5   ; needBits [byte]
  989. fmInDevice      EQU  6   ; device number [byte]
  990. fmInNumer       EQU  8   ; numerator of scale [fixed]
  991. fmInDenom       EQU  12  ; denominator of scale [fixed]
  992.  
  993.  
  994. ; Font Manager Output record (FMgrOutRec)
  995.  
  996. fmOutError      EQU  0   ; error code [word]
  997. fmOutFontH      EQU  2   ; the actual font [handle]
  998. fmOutBold       EQU  6   ; bolding factor [byte]
  999. fmOutItalic     EQU  7   ; italic factor [byte]
  1000. fmOutULOffset   EQU  8   ; underline offset [byte]
  1001. fmOutULShadow   EQU  9   ; underline halo [byte]
  1002. fmOutULThick    EQU  10  ; underline thickness [byte]
  1003. fmOutShadow     EQU  11  ; shadow factor [byte]
  1004. fmOutExtra      EQU  12  ; extra horizontal width [byte]
  1005. fmOutAscent     EQU  13  ; height above baseline [byte]
  1006. fmOutDescent    EQU  14  ; height below baseline [byte]
  1007. fmOutWidMax     EQU  15  ; maximum width of character [byte]
  1008. fmOutLeading    EQU  16  ; space between lines [byte]
  1009. fmOutNumer      EQU  18  ; point for numerators of scale factor [long]
  1010. fmOutDenom      EQU  22  ; point for denominators of scale factor [long]
  1011.  
  1012.  
  1013. ;WidthTable data structure
  1014.  
  1015. widTabData    EQU    0     ;ARRAY[1..256] OF LONGINT character widths
  1016. widTabFont    EQU    1024  ;Handle  font record used to build table
  1017. widthSExtra   EQU    1028  ;LONGINT space extra used for table
  1018. widthStyle    EQU    1032  ;LONGINT extra due to style
  1019. widthFID      EQU    1036  ;INTEGER font family ID
  1020. widthFSize    EQU    1038  ;INTEGER font size request
  1021. widthFace     EQU    1040  ;INTEGER style (face) request
  1022. widthDevice   EQU    1042  ;INTEGER device requested
  1023. widthVInScale EQU    1044  ;FIXED scale factors requested
  1024. widthHInScale EQU    1048  ;FIXED scale factors requested
  1025. widthAFID     EQU    1052  ;INTEGER actual font family ID for table
  1026. widthFHand    EQU    1054  ;Handle family record used to build up table
  1027. widthUsedFam  EQU    1058  ;BOOLEAN used fixed point family widths
  1028. widthAFace    EQU    1059  ;BYTE actual face produced
  1029. widthVOutput  EQU    1060  ;INTEGER vertical scale output value
  1030. widthHOutput  EQU    1062  ;INTEGER horizontal scale output value
  1031. widthVFactor  EQU    1064  ;INTEGER vertical scale output value
  1032. widthHFactor  EQU    1066  ;INTEGER horizontal scale output value
  1033. widthASize    EQU    1068  ;INTEGER actual size of actual font used
  1034. widTabSize    EQU    1070  ;INTEGER total size of table
  1035.  
  1036. ; Font Family Definition
  1037.  
  1038. ffFlags         EQU  0   ; flags for family (word)
  1039. ffFamID         EQU  2   ; family ID number (word)
  1040. ffFirst         EQU  4   ; ASCII code of first character (word)
  1041. ffLast          EQU  6   ; ASCII code of last character (word)
  1042. ffAscent        EQU  8   ; maximum ascent expressed for 1 pt (word)
  1043. ffDescent       EQU  10  ; maximum descent expressed for 1 pt (word)
  1044. ffLeading       EQU  12  ; maximum leading expressed for 1 pt (word)
  1045. ffWidMax        EQU  14  ; maximum widMax expressed for 1 pt (word)
  1046. ffWTabOff       EQU  16  ; offset to width table (long)
  1047. ffKernOff       EQU  20  ; offset to kerning table (long)
  1048. ffStylOff       EQU  24  ; offset to style mapping table (long)
  1049. ffProperty      EQU  28  ; style property info (12 words)
  1050. ffIntl          EQU  52  ; reserved for international use (2 words)
  1051. ffVersion       EQU  56  ; FOND version number
  1052.  
  1053. ; Font Characterization Table
  1054.  
  1055. dpiVert         EQU  0   ; vertical dots per inch [word]
  1056. dpiHoriz        EQU  2   ; horizontal dots per inch [word]
  1057. boldChr         EQU  4   ; bold characteristics [3 bytes]
  1058. italChr         EQU  7   ; italic characteristics [3 bytes]
  1059.                                  ; unused [3 bytes]
  1060. outlineChr      EQU  13  ; outline characteristics [3 bytes]
  1061. shadowChr       EQU  16  ; shadow characteristics [3 bytes]
  1062. condChr         EQU  19  ; condensed characteristics [3 bytes]
  1063. extendChr       EQU  22  ; extended characteristics [3 bytes]
  1064. underChr        EQU  25  ; underline characteristics [3 bytes]
  1065.  
  1066. ; Globals
  1067.  
  1068. CurFMFamily     EQU  $988    ; current font family
  1069. CurFMSize       EQU  $98A    ; current font size
  1070. CurFMFace       EQU  $98C    ; current font face
  1071. CurFMNeedBits   EQU  $98D    ; boolean specifying whether it needs strike
  1072. CurFMDevice     EQU  $98E    ; current font device
  1073. CurFMNumer      EQU  $990    ; current numerator of scale factor
  1074. CurFMDenom      EQU  $994    ; current denominator of scale factor
  1075.  
  1076. FOutRec         EQU  $998    ; Font Manager output record
  1077.  
  1078. FMDotsPerInch   EQU  $9B2    ; h,v dotsPerInch of current device
  1079. FMStyleTab      EQU  $9B6    ; style heuristic table supplied by device
  1080.  
  1081. RomFont0        EQU  $980    ; system font [handle]
  1082. GotStrike       EQU  $986    ; Do we have the strike? [byte]
  1083. \ ,132
  1084. 132
  1085. Event Manager Definitions.
  1086.  
  1087. CONST
  1088.  
  1089.       everyEvent    = - 1;
  1090.       NullEvent     = 0;
  1091.       mouseDown     = 1;
  1092.       mouseUp       = 2;
  1093.       keyDown       = 3;
  1094.       keyUp         = 4;
  1095.       autoKey       = 5;
  1096.       updateEvt     = 6;
  1097.       diskEvt       = 7;
  1098.       activateEvt   = 8;
  1099.       networkEvt    = 10;
  1100.       driverEvt     = 11;
  1101.       app1Evt       = 12;
  1102.       app2Evt       = 13;
  1103.       app3Evt       = 14;
  1104.       app4Evt       = 15;
  1105.  
  1106.       { event mask equates }
  1107.       mDownMask     = 2;
  1108.       mUpMask       = 4;
  1109.       keyDownMask   = 8;
  1110.       keyUpMask     = 16;
  1111.       autoKeyMask   = 32;
  1112.       updateMask    = 64;
  1113.       diskMask      = 128;
  1114.       activMask     = 256;
  1115.       networkMask   = 1024;
  1116.       driverMask    = 2048;
  1117.       app1Mask      = 4096;
  1118.       app2Mask      = 8192;
  1119.       app3Mask      = 16384;
  1120.       app4Mask      = - 32768;
  1121.  
  1122.       {to decipher event message for keyDown events}
  1123.       charCodeMask  = $000000FF;
  1124.       keyCodeMask   = $0000FF00;
  1125.  
  1126.       { modifiers }
  1127.       optionKey     = 2048; { Bit 3 of high byte }
  1128.       alphaLock     = 1024; { Bit 2 }
  1129.       ShiftKey      = 512;  { Bit 1 }
  1130.       CmdKey        = 256;  { Bit 0 }
  1131.       BtnState      = 128;  { Bit 7 of low byte is mouse button state }
  1132.       ControlKey    =  4096;{set if Control key down}
  1133.  
  1134.       activeFlag    = 1;    { bit 0 of modifiers for activate event }
  1135.  
  1136.       EnterKey      = $03;
  1137.       BSKey         = $08
  1138.       TabKey        = $09
  1139.       CRKey         = $0D
  1140.       ESCKey        = $1B
  1141.       LeftArrowKey  = $1C
  1142.       RightArrowKey = $1D
  1143.       UpArrowKey    = $1E
  1144.       DownArrowKey  = $1F
  1145.  
  1146.       {error for PostEvent}
  1147.       EvtNotEnb     = 1;
  1148.  
  1149. TYPE
  1150.  
  1151.       EventRecord = RECORD
  1152.                       what: INTEGER;
  1153.                       message: LongInt;
  1154.                       when: LongInt;
  1155.                       where: Point;
  1156.                       modifiers: INTEGER;
  1157.                     END;
  1158.  
  1159.       KeyMap = PACKED ARRAY [0..127] OF BOOLEAN;
  1160.  
  1161. \ ,133
  1162. 133
  1163. Window Manager Definitions.
  1164.  
  1165. CONST
  1166.  
  1167.       {window messages}
  1168.       wDraw     = 0;
  1169.       wHit      = 1;
  1170.       wCalcRgns = 2;
  1171.       wNew      = 3;
  1172.       wDispose  = 4;
  1173.       wGrow     = 5;
  1174.       wDrawGIcon = 6;
  1175.  
  1176.       {types of windows}
  1177.       dialogKind    = 2;
  1178.       userKind      = 8;
  1179.  
  1180.       {desk pattern resource ID}
  1181.       deskPatID     = 16;
  1182.  
  1183.       {window definition procedure IDs}
  1184.       documentProc  = 0;
  1185.       dBoxProc      = 1;
  1186.       plainDBox     = 2;
  1187.       altDBoxProc   = 3;
  1188.       noGrowDocProc = 4;
  1189.       zoomDocProc   = 8;
  1190.       zoomNoGrow    = 12;
  1191.       rDocProc      = 16;
  1192.  
  1193.       {FindWindow Result Codes}
  1194.       inDesk        = 0;
  1195.       inMenuBar     = 1;
  1196.       inSysWindow   = 2;
  1197.       inContent     = 3;
  1198.       inDrag        = 4;
  1199.       inGrow        = 5;
  1200.       inGoAway      = 6;
  1201.  
  1202.       {new 128K ROM}
  1203.       inZoomIn      = 7;
  1204.       inZoomOut     = 8;
  1205.  
  1206.       {defProc hit test codes}
  1207.       wNoHit        = 0;
  1208.       wInContent    = 1;
  1209.       wInDrag       = 2;
  1210.       wInGrow       = 3;
  1211.       wInGoAway     = 4;
  1212.  
  1213.       {new 128K ROM}
  1214.       wInZoomIn     = 5;
  1215.       wInZoomOut    = 6;
  1216.  
  1217.       {axis constraints for DragGrayRgn call}
  1218.       noConstraint  = 0;
  1219.       hAxisOnly     = 1;
  1220.       vAxisOnly     = 2;
  1221.  
  1222.       wContentColor    = 0;
  1223.       wFrameColor      = 1;
  1224.       wTextColor       = 2;
  1225.       wHiliteColor     = 3;
  1226.       wTitleBarColor   = 4;
  1227.  
  1228. TYPE
  1229.  
  1230.       WindowPtr     = GrafPtr;
  1231.       WindowPeek    = ^WindowRecord;
  1232.       ControlHandle = ^ControlPtr; {for Control Manager}
  1233.  
  1234.       WStateData =  RECORD;
  1235.         userState:  Rect;   {user state}
  1236.         stdState:   Rect    {standard state}
  1237.       END;
  1238.  
  1239.       WindowRecord = RECORD
  1240.                        port: GrafPort;
  1241.                        windowKind: INTEGER;
  1242.                        visible: BOOLEAN;
  1243.                        hilited: BOOLEAN;
  1244.                        goAwayFlag: BOOLEAN;
  1245.                        spareFlag: BOOLEAN;
  1246.                        strucRgn: RgnHandle;
  1247.                        contRgn: RgnHandle;
  1248.                        updateRgn: RgnHandle;
  1249.                        windowDefProc: Handle;
  1250.                        dataHandle: Handle;
  1251.                        titleHandle: StringHandle;
  1252.                        titleWidth: INTEGER;
  1253.                        ControlList: ControlHandle;
  1254.                        nextWindow: WindowPeek;
  1255.                        windowPic: PicHandle;
  1256.                        refCon: LongInt;
  1257.                      END;
  1258.  
  1259.     AuxWinHandle    = ^AuxWinPtr;
  1260.     AuxWinPtr   = ^AuxWinRec;
  1261.     AuxWinRec   = RECORD
  1262.         awNext: AuxWinHandle;   {handle to next record in list}
  1263.         awOwner: WindowPtr;     {pointer to owning window}
  1264.         awCTable: CTabHandle;   {handle to window's color table}
  1265.         dialogCItem: CTabHandle;{private storage for Dialog Manager}
  1266.         awFlags: LONGINT;       {reserved for future use}
  1267.         awReserved: CTabHandle; {reserved for future use}
  1268.         awRefCon: LONGINT       {reserved for application use}
  1269.       END;
  1270.  
  1271.     WTabHandle  = ^WCTabPtr;
  1272.     WCTabPtr    = ^WinCTab;
  1273.     WinCTab = RECORD
  1274.         wCSeed: LONGINT;        {unique identifier from table}
  1275.         wCReserved: INTEGER;    {not used for windows}
  1276.         ctSize: INTEGER;        {number of entries in table –1}
  1277.         ctTable: cSpecArray;    {array of ColorSpec records}
  1278.       END;
  1279.  
  1280.  
  1281. Assembly language.
  1282.                          ; system windows have negative kinds
  1283. dialogKind      EQU  2   ; dialog windows
  1284. userKind        EQU  8   ; this and above numbers are for user
  1285.  
  1286. ; Values returned by window definition function's hit routine
  1287.  
  1288. wNoHit          EQU  0   ; not in window at all
  1289. wInContent      EQU  1   ; in content area
  1290. wInDrag         EQU  2   ; in drag area
  1291. wInGrow         EQU  3   ; in grow area
  1292. wInGoAway       EQU  4   ; in go away area
  1293. wInZoomIn       EQU  5   ; in zoom in
  1294. wInZoomOut      EQU  6   ; in zoom out
  1295.  
  1296. ; FindWindow Return Codes
  1297.  
  1298. inDesk          EQU  0   ; not in any window
  1299. inMenuBar       EQU  1   ; in the menu bar
  1300. inSysWindow     EQU  2   ; in a system window
  1301. inContent       EQU  3   ; in content area of user window
  1302. inDrag          EQU  4   ; in drag area of user window
  1303. inGrow          EQU  5   ; in grow area of user window
  1304. inGoAway        EQU  6   ; in go away area of user window
  1305. inZoomIn        EQU  7   ; in zoom in part code
  1306. inZoomOut       EQU  8   ; in zoom out part code
  1307.  
  1308. ; Resource ID's for windows
  1309.  
  1310. deskPatID       EQU  16  ; desk pattern PAT ID
  1311.  
  1312. documentProc    EQU  0   ; standard document WDEF ID
  1313. dBoxProc        EQU  1   ; dialog box (document without titleBar) WDEF ID
  1314. plainDBox       EQU  2   ; no border WDEF ID
  1315. altDBoxProc     EQU  3   ; no shadow or title WDEF ID
  1316. noGrowDocProc   EQU  4   ; no grow area WDEF ID
  1317. zoomDocProc     EQU  8   ; with zoom box WDEF ID
  1318. zoomNoGrow      EQU 12   ; zoom with no grow box WDEF ID
  1319. rDocProc        EQU 16   ; document with rounded corners WDEF ID
  1320.  
  1321. ; Window Data Structure Definition
  1322.  
  1323. windowPort      EQU  0   ; grafPort [108 bytes]
  1324. windowKind      EQU  $6C     ; type of window [word]
  1325. wVisible        EQU  $6E     ; visible flag [byte]
  1326. wHilited        EQU  $6F     ; select (hilite) flag [byte]
  1327. wGoAway         EQU  $70     ; has go away button [byte]
  1328. wZoom           EQU  $71     ; has zoom box [byte]
  1329. structRgn       EQU  $72     ; structure region of window [Handle]
  1330. contRgn         EQU  $76     ; content region of window [Handle]
  1331. updateRgn       EQU  $7A     ; update region of window [Handle]
  1332. windowDef       EQU  $7E     ; window definition procedure [Handle]
  1333. wDataHandle     EQU  $82     ; window proc-defined data [Handle]
  1334. wTitleHandle    EQU  $86     ; title string [Handle]
  1335. wTitleWidth     EQU  $8A     ; width in pixels of title string [word]
  1336. wControlList    EQU  $8C     ; control list of this window [handle]
  1337. nextWindow      EQU  $90     ; next window in z-ordered list [pointer]
  1338. windowPic       EQU  $94     ; picture handle for updates [handle]
  1339. wRefCon         EQU  $98     ; application use [long]
  1340. windowSize      EQU  $9C     ; size of window data structure
  1341.  
  1342. WStateData      RECORD  0
  1343. userState       DS.L    2       ;Rect
  1344. stdState        DS.L    2       ;Rect
  1345.                 ENDR
  1346.  
  1347. ; Window Manager Globals
  1348.  
  1349. WindowList      EQU  $9D6    ; Z-ordered linked list of windows [pointer]
  1350. PaintWhite      EQU  $9DC    ; erase newly drawn windows? [word]
  1351. WMgrPort        EQU  $9DE    ; window manager's grafport [pointer]
  1352. GrayRgn         EQU  $9EE    ; rounded gray desk region [handle]
  1353. CurActivate     EQU  $A64    ; window slated for activate event [pointer]
  1354. CurDeactive     EQU  $A68    ; window slated for deactivate event [pointer]
  1355.  
  1356. DragHook        EQU  $9F6    ; user hook during dragging [pointer]
  1357. DeskPattern     EQU  $A3C    ; desk pattern [8 bytes]
  1358. DeskHook        EQU  $A6C    ; hook for painting the desk [pointer]
  1359. GhostWindow     EQU  $A84    ; window hidden from FrontWindow [pointer]
  1360.  
  1361. wDrawMsg        EQU  0   ; draw yourself
  1362. wHitMsg         EQU  1   ; hit test
  1363. wCalcRgnMsg     EQU  2   ; recalculate your regions
  1364. wInitMsg        EQU  3   ; initialize yourself
  1365. wDisposeMsg     EQU  4   ; dispose any private data
  1366. wGrowMsg        EQU  5   ; drag out grow outline
  1367. wGIconMsg       EQU  6   ; draw the grow icon
  1368.  
  1369. OldStructure    EQU  $9E6    ; saved structure region [handle]
  1370. OldContent      EQU  $9EA    ; saved content region [handle]
  1371. SaveVisRgn      EQU  $9F2    ; temporarily saved visRegion [handle]
  1372. CurDeKind       EQU  $A22    ; window kind of deactivated window [word]
  1373. SaveUpdate      EQU  $9DA    ; Enable update accumulation? [word]
  1374. \ ,134
  1375. 134
  1376. Control Manager Definitions.
  1377.  
  1378. CONST
  1379.  
  1380.       {control messages}
  1381.       drawCntl  = 0;
  1382.       testCntl  = 1;
  1383.       calcCRgns = 2;
  1384.       initCntl  = 3;
  1385.       dispCntl  = 4;
  1386.       posCntl   = 5;
  1387.       thumbCntl = 6;
  1388.       dragCntl  = 7;
  1389.       autoTrack = 8;
  1390.  
  1391.       {FindControl Result Codes}
  1392.       inButton      = 10;
  1393.       inCheckbox    = 11;
  1394.       inUpButton    = 20;
  1395.       inDownButton  = 21;
  1396.       inPageUp      = 22;
  1397.       inPageDown    = 23;
  1398.       inThumb       = 129;
  1399.  
  1400.       {control definition proc ID's}
  1401.       pushButProc   = 0;
  1402.       checkBoxProc  = 1;
  1403.       radioButProc  = 2;
  1404.       scrollBarProc = 16;
  1405.  
  1406.       useWFont      = 8;
  1407.  
  1408.       cFrameColor     = 0;
  1409.       cBodyColor      = 1;
  1410.       cTextColor      = 2;
  1411.       cElevatorColor  = 3;
  1412.  
  1413. TYPE
  1414.       ControlPtr = ^ControlRecord;
  1415.  
  1416.       ControlRecord = PACKED RECORD
  1417.                         nextControl: ControlHandle;
  1418.                         contrlOwner: WindowPtr;
  1419.                         contrlRect: Rect;
  1420.                         contrlVis: Byte;
  1421.                         contrlHilite: Byte;
  1422.                         contrlValue: INTEGER;
  1423.                         contrlMin: INTEGER;
  1424.                         contrlMax: INTEGER;
  1425.                         contrlDefProc: Handle;
  1426.                         contrlData: Handle;
  1427.                         contrlAction: ProcPtr;
  1428.                         contrlrfCon: LongInt;
  1429.                         contrlTitle: STR255;
  1430.                       END; {ControlRecord}
  1431.  
  1432.     AuxCtlHandle = ^AuxCtlPtr;
  1433.     AuxCtlPtr    = ^AuxCtlRec;
  1434.     AuxCtlRec    = RECORD
  1435.             acNext: AuxCtlHandle;       {handle to next record }
  1436.             acOwner:    ControlHandle;  {handle to owning }
  1437.             acCTable:   CCTabHandle;    {handle to control's color table}
  1438.             acFlags:    INTEGER;        {miscellaneous flags; }
  1439.             acReserved: LONGINT;        {reserved for future }
  1440.             acRefCon:   LONGINT         {reserved for application use}
  1441.           END;
  1442.  
  1443.     CCTabHandle = ^CCTabPtr;
  1444.     CCTabPtr    = ^CtlCTab;
  1445.     CtlCTab     = RECORD
  1446.             ccSeed: LONGINT;        {not used for controls}
  1447.             ccReserved: INTEGER;    {not used for controls}
  1448.             ctSize: INTEGER;        {number of entries in table –1}
  1449.             ctTable: cSpecArray     {array of ColorSpec records}
  1450.           END;
  1451.  
  1452. Assembly language.
  1453.  
  1454. inButton        EQU  10  ; in a push button
  1455. inCheckBox      EQU  11  ; in a checkBox button
  1456. inUpButton      EQU  20  ; in up button area of a dial
  1457. inDownButton    EQU  21  ; in down button area of a dial
  1458. inPageUp        EQU  22  ; in page up (gray) area of a dial
  1459. inPageDown      EQU  23  ; in page down (gray) area of a dial
  1460. inThumb         EQU  129     ; in thumb area of a dial
  1461.  
  1462. ; Constants for axis parameter of DragGrayRgn and DragControl
  1463.  
  1464. noConstraint    EQU  0   ; free form dragging
  1465. hAxisOnly       EQU  1   ; horizontally only
  1466. vAxisOnly       EQU  2   ; vertically only
  1467.  
  1468. ; Resource ID's for controls
  1469.  
  1470. pushButProc     EQU  0   ; rounded-corner pushButtons CDEF ID
  1471. checkBoxProc    EQU  1   ; check-box type buttons CDEF ID
  1472. radioButProc    EQU  2   ; radio buttons  CDEF ID
  1473. scrollBarProc   EQU  16  ; scrollBar CDEF ID
  1474. useWFont        EQU  8   ; add this to get window font CDEF ID
  1475.  
  1476. sBarPatID       EQU  17  ; scrollBar pattern ID
  1477.  
  1478. ; Control Template
  1479.  
  1480. nextControl     EQU  $0  ; next control in the list [handle]
  1481. contrlOwner     EQU  $4  ; owning window [pointer]
  1482. contrlRect      EQU  $8  ; bounding rectangle [8 bytes]
  1483. contrlVis       EQU  $10     ; visible state [byte]
  1484. contrlHilite    EQU  $11     ; hilite state [byte]
  1485. contrlValue     EQU  $12     ; current value of control [word]
  1486. contrlMin       EQU  $14     ; minimum value of control [word]
  1487. contrlMax       EQU  $16     ; maximum value of control [word]
  1488. contrlDefHandle EQU  $18     ; control definition procedure [handle]
  1489. contrlData      EQU  $1C     ; data for definition proc [handle]
  1490. contrlAction    EQU  $20     ; local actionProc [pointer]
  1491. contrlRFcon     EQU  $24     ; refcon defined by application [long]
  1492. contrlTitle     EQU  $28     ; title string [STRING]
  1493. contrlSize      EQU  $28     ; size of control data structure less title
  1494.  
  1495. ; Control Manager Globals
  1496.  
  1497. DragPattern     EQU  $A34    ; DragTheRgn pattern [8 bytes]
  1498. DragFlag        EQU  $A44    ; implicit parameter to DragControl [word]
  1499. CurDragAction   EQU  $A46    ; implicit actionProc for dragControl [pointer]
  1500.  
  1501. drawCtlMsg      EQU  0   ; draw message
  1502. hitCtlMsg       EQU  1   ; hit test message
  1503. calcCtlMsg      EQU  2   ; calc region message
  1504. newCtlMsg       EQU  3   ; init message
  1505. dispCtlMsg      EQU  4   ; dispose any private data message
  1506. posCtlMsg       EQU  5   ; adjust indicator position message
  1507. thumbCtlMsg     EQU  6   ; calculate rectangles for thumb dragging
  1508. dragCtlMsg      EQU  7   ; custom drag message
  1509. trackCtlMsg     EQU  8   ; track yourself message
  1510. \ ,135
  1511. 135
  1512. Menu Manager Definitions.
  1513.  
  1514. CONST
  1515.       noMark        = 0; { mark symbol for MarkItem }
  1516.       TextMenuProc  = 0;
  1517.  
  1518.       hMenuMark  = $C8;  {'»' character indicates a hierarchical menu}
  1519.  
  1520.       hMenuCmd      = $1B;  {itemCmd == $1B ==> hierarchical menu}
  1521.       scriptMenuCmd = $1C;  {itemCmd == $1C ==> item displayed in script font}
  1522.       altMenuCmd1   = $1D;  {itemCmd == $1D ==> unused indicator, reserved}
  1523.       altMenuCmd2   = $1E;  {itemCmd == $1E ==> unused indicator, reserved}
  1524.       altMenuCmd3   = $1F;  {itemCmd == $1F ==> unused indicator, reserved}
  1525.  
  1526.       hierMenu      = -1;    {a hierarchical menu - for InsertMenu call}
  1527.       mbRightDir    = 0;     {menu went to the right (direction)}
  1528.       mbLeftDir     = 1;     {menu went to the left (direction)}
  1529.  
  1530.       { menu defProc messages }
  1531.       mDrawMsg      = 0;
  1532.       mChooseMsg    = 1;
  1533.       mSizeMsg      = 2;
  1534.  
  1535. TYPE
  1536.       MenuPtr       = ^MenuInfo;
  1537.       MenuHandle    = ^MenuPtr;
  1538.       MenuInfo      = RECORD
  1539.                        menuId: INTEGER;
  1540.                        menuWidth: INTEGER;
  1541.                        menuHeight: INTEGER;
  1542.                        menuProc: Handle;
  1543.                        enableFlags: LongInt;
  1544.                        menuData: STR255;
  1545.                      END;
  1546.  
  1547. Assembly language.
  1548.  
  1549. ;  "ASCII" marks for menu characters
  1550.  
  1551. noMark          EQU  0
  1552. commandMark     EQU  $11     ; command fan (cloverleaf)
  1553. checkMark       EQU  $12     ; check mark for menus
  1554. diamondMark     EQU  $13     ; diamond mark for menus
  1555. appleMark       EQU  $14     ; desk ornament menu title
  1556.  
  1557. ; MenuList Data Structure Definition -- one per menuBar
  1558.  
  1559.                          ; 6 Byte header
  1560. lastMenu        EQU  0   ; number of bytes in this menuList [word]
  1561. lastRight       EQU  2   ; h coordinate of 1st free point in menuBar [word]
  1562.                                  ; one of the following per menu
  1563. menuoH          EQU  0   ; menu handle [handle]
  1564. menuLeft        EQU  4   ; coordinate of left edge of menu [word]
  1565.  
  1566. ; MenuInfo Data Structure -- one per menu
  1567.  
  1568. menuID          EQU  0   ; unique ID for each menuBar [word]
  1569. menuWidth       EQU  2   ; menu width [word]
  1570. menuHeight      EQU  4   ; menu height [word]
  1571. menuDefHandle   EQU  6   ; menu definition proc [handle]
  1572. menuEnable      EQU  $A  ; enable flags, one bit/item [long]
  1573. menuData        EQU  $E  ; menu item string [STRING]
  1574. menuBlkSize     EQU  $E  ; size of a menu block plus dataString
  1575.  
  1576. ; MenuString Data Structure -- one per menu item
  1577.  
  1578. itemIcon        EQU  0   ; icon byte
  1579. itemCmd         EQU  1   ; apple (command key) byte
  1580. itemMark        EQU  2   ; checkmark character byte
  1581. itemStyle       EQU  3   ; style byte
  1582.  
  1583. ; Menu Manager Globals
  1584.  
  1585. MenuList        EQU  $A1C    ; current menuBar list structure [handle]
  1586. MenuFlash       EQU  $A24    ; flash feedback count [word]
  1587. MenuHook        EQU  $A30    ; user hook during menuSelect [pointer]
  1588. MBarEnable      EQU  $A20    ; menuBar enable for desk accessories[word]
  1589. MBarHook        EQU  $A2C    ; user hook during menuSelect [pointer]
  1590.  
  1591. ;new Menu Manager stuff
  1592.  
  1593. MBarHeight  EQU    $BAA         ; (word) height of menu bar (usually 20)
  1594.  
  1595. ; Menu Definition Procedure Messages
  1596.  
  1597. mDrawMsg        EQU  0   ; draw yourself
  1598. mChooseMsg      EQU  1   ; select an item
  1599. mSizeMsg        EQU  2   ; calculate your size
  1600.  
  1601. ; Menu Resource IDs
  1602.  
  1603. textMenuProc    EQU  0   ; standard text menu MDEF ID
  1604.  
  1605. maxMenu         EQU  $60     ; maximum of 16*6 menus in menuBar
  1606. mListSize       EQU  $66     ; menu list is 102 bytes long
  1607.  
  1608. TheMenu         EQU  $A26    ; ID of hilited menu [word]
  1609. SavedHandle     EQU  $A28    ; saved bits under a menu [handle]
  1610.  
  1611. ;misc Menu stuff
  1612.  
  1613. MrMacHook       EQU  $A2C    ; Mr. Macintosh hook [pointer]
  1614. \ ,136
  1615. 136
  1616. TextEdit Definitions.
  1617.  
  1618. CONST
  1619.       teJustLeft    = 0;
  1620.       teJustRight   = - 1;
  1621.       teJustCenter  = 1;
  1622.  
  1623.       doFont        = 1; { set font (family) number }
  1624.       doFace        = 2; { set character style  }
  1625.       doSize        = 4; { set type size    }
  1626.       doColor       = 8; { set color     }
  1627.       doAll         = 15; { set all attributes  }
  1628.       addSize       = 16; { adjust type size   }
  1629.  
  1630. TYPE
  1631.       TERec = RECORD
  1632.                 destRect: Rect;         {Destination rectangle}
  1633.                 viewRect: Rect;         {view rectangle}
  1634.                 selRect: Rect;          {Select rectangle}
  1635.                 lineHeight: INTEGER;    {Current font lineheight}
  1636.                 fontAscent: INTEGER;    {Current font ascent}
  1637.                 selPoint: Point;        {Selection point(mouseLoc)}
  1638.  
  1639.                 selStart: INTEGER;      {Selection start}
  1640.                 selEnd: INTEGER;        {Selection end}
  1641.  
  1642.                 active: INTEGER;        {<>0 if active}
  1643.  
  1644.                 wordBreak: ProcPtr;     {Word break routine}
  1645.                 clikLoop: ProcPtr;      {Click loop routine}
  1646.  
  1647.                 clickTime: LongInt;     {Time of first click}
  1648.                 clickLoc: INTEGER;      {Char. location of click}
  1649.  
  1650.                 caretTime: LongInt;     {Time for next caret blink}
  1651.                 caretState: INTEGER;    {On/active booleans}
  1652.  
  1653.                 just: INTEGER;          {fill style}
  1654.  
  1655.                 teLength: INTEGER;      {Length of text below}
  1656.                 hText: Handle;          {Handle to actual text}
  1657.  
  1658.                 recalBack: INTEGER;     {<>0 if recal in background}
  1659.                 recalLines: INTEGER;    {Line being recal'ed}
  1660.                 clikStuff: INTEGER;     {click stuff (internal)}
  1661.  
  1662.                 crOnly: INTEGER;        {Set to -1 if CR line breaks only}
  1663.  
  1664.                 txFont: INTEGER;        {Text Font}
  1665.                 txFace: Style;          {Text Face}
  1666.                 txMode: INTEGER;        {Text Mode}
  1667.                 txSize: INTEGER;        {Text Size}
  1668.  
  1669.                 inPort: GrafPtr;        {Grafport}
  1670.  
  1671.                 highHook: ProcPtr;      {Highlighting hook}
  1672.                 caretHook: ProcPtr;     {Highlighting hook}
  1673.  
  1674.                 nLines: INTEGER;        {Number of lines}
  1675.                 lineStarts: ARRAY [0..16000] OF INTEGER;
  1676.                                         {Actual line starts
  1677.                                         themselves}
  1678.               END;                      {RECORD}
  1679.       TEPtr = ^TERec;
  1680.       TEHandle = ^TEPtr;
  1681.  
  1682.       CharsHandle = ^CharsPtr;
  1683.       CharsPtr = ^Chars;
  1684.       Chars = PACKED ARRAY [0..32000] OF CHAR;
  1685.  
  1686.     TEStyleHandle = ^TEStylePtr;
  1687.     TEStylePtr = ^TEStyleRec;
  1688.     TEStyleRec = RECORD
  1689.         nRuns: INTEGER;     {number of style runs}
  1690.         nStyles: INTEGER;   {size of style table}
  1691.         styleTab: STHandle; {handle to style table}
  1692.         lhTab: LHHandle;    {handle to line-height table}
  1693.         teRefCon: LONGINT;  {reserved for application use}
  1694.         nullStyle: nullSTHandle; {handle to style set at null selection}
  1695.         runs:   ARRAY [0..0] OF StyleRun
  1696.       END;
  1697.  
  1698.     StyleRun = RECORD
  1699.             startChar: INTEGER; {starting character position}
  1700.             styleIndex: INTEGER {index in style table}
  1701.           END;
  1702.  
  1703.     STHandle    = ^STPtr;
  1704.     STPtr   = ^TEStyleTable;
  1705.     TEStyleTable    = ARRAY [0..0] OF STElement;
  1706.     STElement   = RECORD
  1707.         stCount: INTEGER;   {number of runs in this style}
  1708.         stHeight: INTEGER;  {line height}
  1709.         stAscent: INTEGER;  {font ascent}
  1710.         stFont: INTEGER;    {font (family) number}
  1711.         stFace: Style;      {character style}
  1712.         stSize: INTEGER;    {size in points}
  1713.         stColor: RGBColor   {absolute (RGB) color}
  1714.       END;
  1715.  
  1716.     LHHandle    = ^LHPtr;
  1717.     LHPtr   = ^LHTable;
  1718.     LHTable = ARRAY [0..0] OF LHElement;
  1719.     LHElement   = RECORD
  1720.         lhHeight: INTEGER;  {maximum height in line}
  1721.         lhAscent: INTEGER   {maximum ascent in line}
  1722.       END;
  1723.  
  1724.     NullSTHandle = ^NullSTPtr;
  1725.     NullSTPtr = ^NullSTRec;
  1726.     NullSTRec = RECORD
  1727.         TEReserved: LONGINT;        {reserved for future expansion}
  1728.         nullScrap:  STScrpHandle    {handle to scrap style table}
  1729.       END;
  1730.  
  1731.     TextStyle   = RECORD
  1732.         tsFont: INTEGER;    {font (family) number}
  1733.         tsFace: Style;      {character style}
  1734.         tsSize: INTEGER;    {size in points}
  1735.         tsColor: RGBColor   {absolute (RGB) color}
  1736.       END;
  1737.  
  1738.     StScrpHandle = ^StScrpPtr;
  1739.     StScrpPtr = ^StScrpRec;
  1740.     StScrpRec = RECORD
  1741.         scrpNStyles: INTEGER;   {number of distinct styles in scrap}
  1742.         scrpStyleTab: ScrpSTTable   {table of styles for scrap}
  1743.       END;
  1744.  
  1745.     ScrpSTTable = ARRAY [0..0] OF scrpSTElement;
  1746.     ScrpSTElement   = RECORD
  1747.         scrpStartChar: LONGINT; {offset to start of style}
  1748.         scrpHeight: INTEGER;    {line height}
  1749.         scrpAscent: INTEGER;    {font ascent}
  1750.         scrpFont: INTEGER;      {font (family) number}
  1751.         scrpFace: Style;        {character style}
  1752.         scrpSize: INTEGER;      {size in points}
  1753.         scrpColor: RGBColor;    {absolute (RGB) color}
  1754.       END;
  1755.  
  1756. Assembly language.
  1757.  
  1758. ; Justification styles
  1759.  
  1760. teJustLeft      EQU  0   ; left justified text
  1761. teJustRight     EQU  -1  ; right justified text
  1762. teJustCenter    EQU  1   ; center justified text
  1763.  
  1764. ; Text Edit Record
  1765.  
  1766. teDestRect      EQU  $0  ; destination rectangle  [8 bytes]
  1767. teViewRect      EQU  $8  ; view rectangle rectangle [8 bytes]
  1768.  
  1769. teSelRect       EQU  $10     ; select rectangle [8 bytes]
  1770. teLineHite      EQU  $18     ; lineheight [word]
  1771. teAscent        EQU  $1A     ; first baseline offset [word]
  1772. teSelPoint      EQU  $1C     ; selection point [long]
  1773.  
  1774. teSelStart      EQU  $20     ; selection start [word]
  1775. teSelEnd        EQU  $22     ; selection end [word]
  1776.  
  1777. teActive        EQU  $24     ; active [byte]
  1778.  
  1779. teWordBreak     EQU  $26     ; word break routine [pointer]
  1780. teClikProc      EQU  $2A     ; click loop routine [pointer]
  1781.  
  1782. teClikTime      EQU  $2E     ; time of last click [long]
  1783. teClikLoc       EQU  $32     ; location of double click [long]
  1784.  
  1785. teCarTime       EQU  $34     ; time for next caret toggle [long]
  1786. teCarOn         EQU  $38     ; is caret on? [byte]
  1787. teCarAct        EQU  $39     ; is caret active? [byte]
  1788. teJust          EQU  $3A     ; fill style [word]
  1789.  
  1790. teLength        EQU  $3C     ; length of text below [word]
  1791. teTextH         EQU  $3E     ; text [handle]
  1792.  
  1793. teRecBack       EQU  $42     ; unused [word]
  1794. teRecLine       EQU  $44     ; unused [word]
  1795. teLftClick      EQU  $46     ; click was to left? [byte]
  1796. teLftCaret      EQU  $47     ; caret was to left? [byte]
  1797.  
  1798. teCROnly        EQU  $48     ; <CR> only for line breaks? [byte]
  1799.  
  1800. teFontStuff     EQU  $4A     ; space for font specifier [8 bytes]
  1801. teFont          EQU  $4A     ; text font [word]
  1802. teFace          EQU  $4C     ; text face [word]
  1803. teMode          EQU  $4E     ; text mode [word]
  1804. teSize          EQU  $50     ; text size [word]
  1805. teGrafPort      EQU  $52     ; grafport for editting [pointer]
  1806.  
  1807. teHiHook        EQU  $56     ; hook for hilite routine [pointer]
  1808. teCarHook       EQU  $5A     ; hook for hilite routine [pointer]
  1809.  
  1810. teNLines        EQU  $5E     ; number of lines [word]
  1811. teLines         EQU  $60     ; line starts [words...]
  1812.  
  1813. teRecSize       EQU  $68     ; base size of a record w/o lines
  1814.  
  1815. ; Text Edit Globals
  1816.  
  1817. TEScrpLength    EQU  $AB0    ; textEdit Scrap Length [word]
  1818. TEScrpHandle    EQU  $AB4    ; textEdit Scrap [handle]
  1819. TEWdBreak       EQU  $AF6    ; default word break routine [pointer]
  1820. TEDoText        EQU  $A70    ; textEdit doText proc hook [pointer]
  1821. TERecal         EQU  $A74    ; textEdit recalText proc hook [pointer]
  1822.  
  1823. ;new TE stuff
  1824.  
  1825. WordRedraw  EQU    $BA5         ; (byte) - used by TextEdit RecalDraw
  1826. TESysJust   EQU    $BAC         ; (word) system justification (intl. textEdit)
  1827. TEFlags     EQU    teRecBack    ; turn whole byte into bit flags
  1828. teFAutoPos  EQU    6            ; set this bit for auto position/scroll
  1829. \ ,137
  1830. 137
  1831. Dialog Manager Definitions.
  1832.  
  1833. CONST
  1834.       userItem  = 0;
  1835.       ctrlItem  = 4;
  1836.       btnCtrl   = 0;    { Low two bits specify what kind of control }
  1837.       chkCtrl   = 1;
  1838.       radCtrl   = 2;
  1839.       resCtrl   = 3;
  1840.  
  1841.       statText      = 8;        { Static text }
  1842.       editText      = 16;       { Editable text }
  1843.       iconItem      = 32;       { Icon item }
  1844.       picItem       = 64;       { Picture item }
  1845.       itemDisable   = 128;      { Disable item if set }
  1846.  
  1847.       ok        = 1;        { OK button is first by convention }
  1848.       cancel    = 2;        { Cancel button is second by convention }
  1849.  
  1850.       stopIcon      = 0;
  1851.       noteIcon      = 1;
  1852.       cautionIcon   = 2;
  1853.  
  1854. { Constants for TextEdit and dialog boxes }
  1855.    TEdoFont     =  1;   {set font (family) number}
  1856.    TEdoFace     =  2;   {set character style}
  1857.    TEdoSize     =  4;   {set type size}
  1858.    TEdoColor    =  8;   {set foreground color}
  1859.    TEdoAll      = 15;   {set all attributes}
  1860.    TEaddSize    = 16;   {adjust type size}
  1861.  
  1862. { Constants for dialog boxes only }
  1863.    doBColor     = 8192;     {set background color}
  1864.    doMode       = 16384;    {set txMode}
  1865.    doFontName   = 32768;    {set txFont from name}
  1866.  
  1867.  
  1868. TYPE
  1869.       DialogPtr    = WindowPtr;
  1870.       DialogPeek   = ^DialogRecord;
  1871.       DialogRecord = RECORD
  1872.                        window: WindowRecord;
  1873.                        Items: Handle;
  1874.                        textH: TEHandle;
  1875.                        editField: INTEGER;
  1876.                        editOpen: INTEGER;
  1877.                        aDefItem: INTEGER;
  1878.                      END;
  1879.  
  1880.       DialogTHndl = ^DialogTPtr;
  1881.       DialogTPtr = ^DialogTemplate;
  1882.       DialogTemplate = RECORD
  1883.                          boundsRect: Rect;
  1884.                          procID: INTEGER;
  1885.                          visible: BOOLEAN;
  1886.                          filler1: BOOLEAN;
  1887.                          goAwayFlag: BOOLEAN;
  1888.                          filler2: BOOLEAN;
  1889.                          refCon: LongInt;
  1890.                          ItemsID: INTEGER;
  1891.                          title: STR255;
  1892.                        END;
  1893.  
  1894.       StageList = PACKED RECORD
  1895.                     boldItm4: 0..1;
  1896.                     boxDrwn4: BOOLEAN;
  1897.                     sound4: 0..3;
  1898.                     boldItm3: 0..1;
  1899.                     boxDrwn3: BOOLEAN;
  1900.                     sound3: 0..3;
  1901.                     boldItm2: 0..1;
  1902.                     boxDrwn2: BOOLEAN;
  1903.                     sound2: 0..3;
  1904.                     boldItm1: 0..1;
  1905.                     boxDrwn1: BOOLEAN;
  1906.                     sound1: 0..3;
  1907.                   END;
  1908.  
  1909.       AlertTHndl = ^AlertTPtr;
  1910.       AlertTPtr = ^AlertTemplate;
  1911.       AlertTemplate = RECORD
  1912.                         boundsRect: Rect;
  1913.                         ItemsID: INTEGER;
  1914.                         stages: StageList;
  1915.                       END;
  1916.  
  1917. Assembly language.
  1918.  
  1919. ; Item codes in item list
  1920.  
  1921. userItem        EQU  0   ; application-defined (dialog only)
  1922. ctrlItem        EQU  4   ; must be added to following four items
  1923. btnCtrl         EQU  0   ; standard button
  1924. chkCtrl         EQU  1   ; standard check box
  1925. radCtrl         EQU  2   ; standard radio button
  1926. resCtrl         EQU  3   ; control defined in resource file
  1927. statText        EQU  8   ; static text
  1928. editText        EQU  16  ; editable text (dialog only)
  1929. iconItem        EQU  32  ; icon
  1930. picItem         EQU  64  ; quickdraw picture
  1931. itemDisable     EQU  128     ; add to any of above to disable
  1932.  
  1933.  
  1934. ; Generic buttons
  1935.  
  1936. okButton        EQU  1   ; OK button
  1937. cancelButton    EQU  2   ; Cancel button
  1938.  
  1939. ; Alert/Dialog Resource ID's
  1940.  
  1941. stopIcon        EQU  0   ; stop icon ID
  1942. noteIcon        EQU  1   ; note icon ID
  1943. cautionIcon     EQU  2   ; caution icon ID
  1944.  
  1945. ; Dialog Template
  1946.  
  1947. dBounds         EQU  $0     ; dialog bounds rectangle
  1948. dWindProc       EQU  $8     ; window proc ID
  1949. dVisible        EQU  $A     ; visible flag
  1950. dGoAway         EQU  $C     ; go away flag
  1951. dRefCon         EQU  $E     ; reference constant
  1952. dItems          EQU  $12    ; item list ID and handle
  1953. dTitle          EQU  $14    ; dialog window title
  1954.  
  1955. ; Alert Template
  1956.  
  1957. aBounds         EQU  $0     ; alert box height and width
  1958. aItems          EQU  $8     ; item list ID
  1959. aStages         EQU  $A     ; stages word
  1960.  
  1961. ; Dialog/Alert Window Record
  1962.  
  1963. dWindow         EQU  $0      ; window record
  1964. items           EQU  $9C     ; Item list [handle]
  1965. teHandle        EQU  $A0     ; textEdit object [handle]
  1966. editField       EQU  $A4     ; current field being edited [word]
  1967. editOpen        EQU  $A6     ; is editting open? [word]
  1968. aDefItem        EQU  $A8     ; default item for alerts [word]
  1969. dWindLen        EQU  $AA     ; dialog record length
  1970.  
  1971. ; In each item
  1972.  
  1973. itmHndl         EQU  0   ; handle to the item
  1974. itmRect         EQU  $4  ; bounding rect of item
  1975. itmType         EQU  $C  ; item type
  1976. itmData         EQU  $D  ; item string, must be even length
  1977.  
  1978. ; Dialog Manager Globals
  1979.  
  1980. ANumber         EQU  $A98    ; active alert ID [word]
  1981. ACount          EQU  $A9A    ; # times this alert called [word]
  1982. DABeeper        EQU  $A9C    ; beep routine [pointer]
  1983. DAStrings       EQU  $AA0    ; paramText substutution strings [4 handles]
  1984. DlgFont         EQU  $AFA    ; default dialog font ID [word]
  1985. \ ,138
  1986. 138
  1987. Desk Manager Definitions.
  1988.  
  1989. CONST (Assembly-Language)
  1990.  
  1991. drvrFlags       EQU  $0     ; various flags and permissions [word]
  1992. drvrDelay       EQU  $2     ; # of ticks between systask calls [word]
  1993. drvrEMask       EQU  $4     ; event mask [word]
  1994. drvrMenu        EQU  $6     ; driver menu ID [word]
  1995. drvrOpen        EQU  $8     ; open routine offset [word]
  1996. drvrPrime       EQU  $A     ; prime routine offset [word]
  1997. drvrCtl         EQU  $C     ; control routine offset [word]
  1998. drvrStatus      EQU  $E     ; status routine offset [word]
  1999. drvrClose       EQU  $10    ; warmstart reset routine offset [word]
  2000. drvrName        EQU  $12    ; length byte and name of driver [string]
  2001.  
  2002. accEvent        EQU  $40    ; event message from SystemEvent
  2003. accRun          EQU  $41    ; run message from SystemTask
  2004. accCursor       EQU  $42    ; cursor message from SystemTask
  2005. accMenu         EQU  $43    ; menu message from SystemMenu
  2006. accUndo         EQU  $44    ; undo message from SystemEdit
  2007. accCut          EQU  $46    ; cut message from SystemEdit
  2008. accCopy         EQU  $47    ; copy message from SystemEdit
  2009. accPaste        EQU  $48    ; paste message from SystemEdit
  2010. accClear        EQU  $49    ; clear message from SystemEdit
  2011.  
  2012. goodBye         EQU  -1     ; goodbye message
  2013.  
  2014. \ ,139
  2015. 139
  2016. Scrap Manager Definitions.
  2017.  
  2018. CONST
  2019.       noScrapErr    = - 100; {desk scrap isn't initialized}
  2020.       noTypeErr     = - 102;
  2021.  
  2022. TYPE
  2023.       ScrapStuff = RECORD
  2024.                      scrapSize: LongInt;
  2025.                      scrapHandle: Handle;
  2026.                      scrapCount: INTEGER;
  2027.                      scrapState: INTEGER;
  2028.                      scrapName: StringPtr;
  2029.                    END;
  2030.       pScrapStuff = ^ScrapStuff;
  2031.  
  2032. \ ,140
  2033. 140
  2034. Toolbox Utilities Definitions.
  2035.  
  2036. CONST
  2037.       sysPatListID  = 0;    {ID of PAT# which contains 38 patterns}
  2038.  
  2039.       iBeamCursor   = 1;    {text selection cursor}
  2040.       crossCursor   = 2;    {for drawing graphics}
  2041.       plusCursor    = 3;    {for structured selection}
  2042.       watchCursor   = 4;    {for indicating a long delay}
  2043.  
  2044. TYPE
  2045.       Int64Bit = RECORD
  2046.                    hiLong: LongInt;
  2047.                    loLong: LongInt;
  2048.                  END;
  2049.  
  2050.       CursPtr = ^Cursor;
  2051.       CursHandle = ^CursPtr;
  2052.  
  2053.       PatPtr = ^Pattern;
  2054.       PatHandle = ^PatPtr;
  2055.  
  2056. \ ,141
  2057. 141
  2058. Package Manager Definitions.
  2059.  
  2060. CONST
  2061.       listMgr   = 0; {list manager}
  2062.       dskInit   = 2; {Disk Initializaton}
  2063.       stdFile   = 3; {Standard File}
  2064.       flPoint   = 4; {Floating-Point Arithmetic}
  2065.       trFunc    = 5; {Transcendental Functions}
  2066.       intUtil   = 6; {International Utilities}
  2067.       bdConv    = 7; {Binary/Decimal Conversion}
  2068.  
  2069.       putDlgID = - 3999; {SFPutFile dialog template ID}
  2070.  
  2071.       putSave = 1;       {save button}
  2072.       putCancel = 2;     {cancel button}
  2073.       putEject = 5;      {eject button}
  2074.       putDrive = 6;      {drive button}
  2075.       putName = 7;       {editTExt item for file name}
  2076.  
  2077.       getDlgID = - 4000; {SFGetFile dialog template ID}
  2078.  
  2079.       getOpen = 1;       {open button}
  2080.       getCancel = 3;     {cancel button}
  2081.       getEject = 5;      {eject button}
  2082.       getDrive = 6;      {drive button}
  2083.       getNmList = 7;     {userItem for file name list}
  2084.       getScroll = 8;     {userItem for scroll bar}
  2085.  
  2086.  TYPE
  2087.  
  2088.    SFReply = RECORD
  2089.                good: BOOLEAN;     {ignore command if FALSE}
  2090.                copy: BOOLEAN;     {not used}
  2091.                fType: OsType;     {file type or not used}
  2092.                vRefNum: INTEGER;  {volume reference number}
  2093.                version: INTEGER;  {file's version number}
  2094.                fName: String[63]; {file name}
  2095.              END;                 {SFReply}
  2096.  
  2097.    SFTypeList = ARRAY [0..3] OF OsType;
  2098.  
  2099. Assembly language.
  2100.  
  2101. AppPacks        EQU  $AB8    ; packages' code [8 handles]
  2102.  
  2103. \ ,142
  2104. 142
  2105. Memory Manager Definition.
  2106.  
  2107. CONST
  2108.   MemFullErr    = - 108; { Not enough room in heap zone }
  2109.   NilHandleErr  = - 109; { Master Pointer was NIL in HandleZone or other }
  2110.   MemWZErr      = - 111; { WhichZone failed (applied to free block) }
  2111.   MemPurErr     = - 112; { trying to purge a locked or non-purgeable block }
  2112.   MemLockedErr  = - 117; { Block is locked }
  2113.   NoErr         = 0;     { All is well }
  2114.  
  2115. TYPE
  2116.       SignedByte    = - 128..127;   { any byte in memory }
  2117.       Byte          = 0..255;       { unsigned byte for fontmgr }
  2118.       Ptr           = ^SignedByte;  { blind pointer }
  2119.       Handle        = ^Ptr;         { pointer to a master pointer }
  2120.       ProcPtr       = Ptr;          { pointer to a procedure }
  2121.       Fixed         = LongInt;      { fixed point arithmetic type }
  2122.  
  2123.       Str255        = String[255];  { maximum string size }
  2124.       StringPtr     = ^Str255;      { pointer to maximum string }
  2125.       StringHandle  = ^StringPtr;   { handle to maximum string }
  2126.  
  2127.       Zone = RECORD
  2128.                BkLim: Ptr;
  2129.                PurgePtr: Ptr;
  2130.                HFstFree: Ptr;
  2131.                ZCBFree: LongInt;
  2132.                GZProc: ProcPtr;
  2133.                MoreMast: INTEGER;
  2134.                Flags: INTEGER;
  2135.                CntRel: INTEGER;
  2136.                MaxRel: INTEGER;
  2137.                CntNRel: INTEGER;
  2138.                MaxNRel: INTEGER;
  2139.                CntEmpty: INTEGER;
  2140.                CntHandles: INTEGER;
  2141.                MinCBFree: LongInt;
  2142.                PurgeProc: ProcPtr;
  2143.                SparePtr: Ptr;       { reserved for future }
  2144.                AllocPtr: Ptr;
  2145.                HeapData: INTEGER;
  2146.              END;
  2147.       THz   = ^Zone;    { pointer to the start of a heap zone }
  2148.       Size  = LongInt;  { size of a block in bytes }
  2149.       OSErr = INTEGER;  { error code }
  2150.  
  2151.       QElemPtr = ^QElem; {ptr to generic queue element}
  2152.  
  2153. \ ,143
  2154. 143
  2155. Segment Loader Definitions.
  2156.  
  2157. CONST
  2158.       appOpen  = 0 ;  { Open the Document (s) }
  2159.       appPrint = 1 ;  { Print the Document (s)}
  2160. TYPE
  2161.       appFile = RECORD
  2162.                   vRefNum: INTEGER;
  2163.                   ftype: OSType;
  2164.                   versNum: INTEGER; {versNum in high byte}
  2165.                   fName: str255;
  2166.                 END; {appFile}
  2167.  
  2168. \ ,144
  2169. 144
  2170. OS Event Definitions.
  2171.  
  2172. CONST
  2173.       NullEvent     = 0;
  2174.       mouseDown     = 1;
  2175.       mouseUp       = 2;
  2176.       keyDown       = 3;
  2177.       keyUp         = 4;
  2178.       autoKey       = 5;
  2179.       updateEvt     = 6;
  2180.       diskEvt       = 7;
  2181.       activateEvt   = 8;
  2182.       networkEvt    = 10;
  2183.       driverEvt     = 11;
  2184.       app1Evt       = 12;
  2185.       app2Evt       = 13;
  2186.       app3Evt       = 14;
  2187.       app4Evt       = 15;
  2188.  
  2189.       { event mask equates }
  2190.       mDownMask     = 2;
  2191.       mUpMask       = 4;
  2192.       keyDownMask   = 8;
  2193.       keyUpMask     = 16;
  2194.       autoKeyMask   = 32;
  2195.       updateMask    = 64;
  2196.       diskMask      = 128;
  2197.       activMask     = 256;
  2198.       networkMask   = 1024;
  2199.       driverMask    = 2048;
  2200.       app1Mask      = 4096;
  2201.       app2Mask      = 8192;
  2202.       app3Mask      = 16384;
  2203.       app4Mask      = - 32768;
  2204.  
  2205.       {to decipher event message for keyDown events}
  2206.       charCodeMask  = $000000FF;
  2207.       keyCodeMask   = $0000FF00;
  2208.  
  2209.       { modifiers }
  2210.       optionKey     = 2048; { Bit 3 of high byte }
  2211.       alphaLock     = 1024; { Bit 2 }
  2212.       ShiftKey      = 512;  { Bit 1 }
  2213.       CmdKey        = 256;  { Bit 0 }
  2214.       BtnState      = 128;  { Bit 7 of low byte is mouse button state }
  2215.  
  2216.       activeFlag    = 1;    { bit 0 of modifiers for activate event }
  2217.  
  2218.       {error for PostEvent}
  2219.       EvtNotEnb     = 1;
  2220.  
  2221. TYPE
  2222.       EventRecord = RECORD
  2223.                       what: INTEGER;
  2224.                       message: LongInt;
  2225.                       when: LongInt;
  2226.                       where: Point;
  2227.                       modifiers: INTEGER;
  2228.                     END;
  2229.  
  2230.       evQEl = RECORD
  2231.                 qLink: QElemPtr;
  2232.                 qType: INTEGER;
  2233.                 evtQwhat: INTEGER; {this part is identical to the EventRecord
  2234.                                     as...}
  2235.                 evtQmessage: LongInt; {defined in ToolIntf}
  2236.                 evtQwhen: LongInt;
  2237.                 evtQwhere: Point;
  2238.                 evtQmodifiers: INTEGER;
  2239.               END;
  2240.  
  2241. \ ,145
  2242. 145
  2243. File Manager Definitions.
  2244.  
  2245. CONST
  2246.   DirFulErr     = - 33; { Directory full }
  2247.   DskFulErr     = - 34; { disk full }
  2248.   NSVErr        = - 35; { no such volume }
  2249.   IOErr         = - 36; { I/O error }
  2250.   BdNamErr      = - 37; { bad name }
  2251.   FNOpnErr      = - 38; { File not open }
  2252.   EOFErr        = - 39; { End of file }
  2253.   PosErr        = - 40; { tried to position to before start of file (r/w) }
  2254.   MFulErr       = - 41; { memory full(open) or file won't fit (load) }
  2255.   TMFOErr       = - 42; { too many files open }
  2256.   FNFErr        = - 43; { File not found }
  2257.  
  2258.   WPrErr        = - 44; { diskette is write protected }
  2259.   FLckdErr      = - 45; { file is locked }
  2260.   VLckdErr      = - 46; { volume is locked }
  2261.   FBsyErr       = - 47; { File is busy (delete) }
  2262.   DupFNErr      = - 48; { duplicate filename (rename) }
  2263.   OpWrErr       = - 49; { file already open with with write permission }
  2264.   ParamErr      = - 50; { error in user parameter list }
  2265.   RFNumErr      = - 51; { refnum error }
  2266.   GFPErr        = - 52; { get file position error }
  2267.   VolOffLinErr  = - 53; { volume not on line error (was Ejected) }
  2268.   PermErr       = - 54; { permissions error (on file open) }
  2269.   VolOnLinErr   = - 55; { drive volume already on-line at MountVol }
  2270.   NSDrvErr      = - 56; { no such drive (tried to mount a bad drive num) }
  2271.   NoMacDskErr   = - 57; { not a mac diskette (sig bytes are wrong) }
  2272.   ExtFSErr      = - 58; { volume in question belongs to an external fs }
  2273.   FSRnErr       = - 59; { file system rename error }
  2274.   BadMDBErr     = - 60; { bad master directory block }
  2275.   WrPermErr     = - 61; { write permissions error }
  2276.  
  2277.   lastDskErr    = - 64; { last in a range of disk errors }
  2278.   noDriveErr    = - 64; { drive not installed }
  2279.   offLinErr     = - 65; { r/w requested for an off-line drive }
  2280.   noNybErr      = - 66; { couldn't find 5 nybbles in 200 tries }
  2281.   noAdrMkErr    = - 67; { couldn't find valid addr mark }
  2282.   dataVerErr    = - 68; { read verify compare failed }
  2283.   badCkSmErr    = - 69; { addr mark checksum didn't check }
  2284.   badBtSlpErr   = - 70; { bad addr mark bit slip nibbles }
  2285.   noDtaMkErr    = - 71; { couldn't find a data mark header }
  2286.   badDCkSum     = - 72; { bad data mark checksum }
  2287.   badDBtSlp     = - 73; { bad data mark bit slip nibbles }
  2288.   wrUnderRun    = - 74; { write underrun occurred }
  2289.   cantStepErr   = - 75; { step handshake failed }
  2290.   tk0BadErr     = - 76; { track 0 detect doesn't change }
  2291.   initIWMErr    = - 77; { unable to initialize IWM }
  2292.   twoSideErr    = - 78; { tried to read 2nd side on a 1-sided drive }
  2293.   spdAdjErr     = - 79; { unable to correctly adjust disk speed }
  2294.   seekErr       = - 80; { track number wrong on address mark }
  2295.   sectNFErr     = - 81; { sector number never found on a track }
  2296.   firstDskErr   = - 84; { first in a range of disk errors }
  2297.  
  2298.   DirNFErr      = - 120; { Directory not found }
  2299.   TMWDOErr      = - 121; { No free WDCB available }
  2300.   BadMovErr     = - 122; { Move into offspring error }
  2301.   WrgVolTypErr  = - 123; { Wrong volume type error - operation not
  2302.                             supported for MFS}
  2303.   FSDSIntErr    = - 127; { Internal file system error }
  2304.  
  2305.   MaxSize       = $800000; { Max data block size is 8 megabytes }
  2306.  
  2307.       {finder constants}
  2308.       fOnDesk       = 1;
  2309.       fHasBundle    = 8192;
  2310.       fInvisible    = 16384;
  2311.       fTrash        = - 3;
  2312.       fDesktop      = - 2;
  2313.       fDisk         = 0;
  2314.  
  2315.       {io constants}
  2316.  
  2317.       {ioPosMode values}
  2318.       fsAtMark      = 0;
  2319.       fsFromStart   = 1;
  2320.       fsFromLEOF    = 2;
  2321.       fsFromMark    = 3;
  2322.       rdVerify      = 64;
  2323.  
  2324.       {ioPermission values}
  2325.       fsCurPerm     = 0;
  2326.       fsRdPerm      = 1;
  2327.       fsWrPerm      = 2;
  2328.       fsRdWrPerm    = 3;
  2329.       fsRdWrShPerm  = 4;
  2330.  
  2331. TYPE
  2332.   ParamBlkType = (IOParam, FileParam, VolumeParam, CntrlParam);
  2333.  
  2334.   OSType = PACKED ARRAY [1..4] OF CHAR; {same as rsrc mgr's Restype}
  2335.  
  2336.   FInfo = RECORD                {record of finder info}
  2337.             fdType: OSType;     {the type of the file}
  2338.             fdCreator: OSType;  {file's creator}
  2339.             fdFlags: INTEGER;   {flags ex. hasbundle,invisible,locked,
  2340.                                     etc.}
  2341.             fdLocation: Point;  {file's location in folder}
  2342.             fdFldr: INTEGER;    {folder containing file}
  2343.           END; {FInfo}
  2344.  
  2345.  
  2346.   FXInfo = RECORD
  2347.              fdIconID: INTEGER;         {Icon ID}
  2348.              fdUnused: ARRAY [1..4] OF INTEGER; {unused but reserved 8 bytes}
  2349.              fdComment: INTEGER;        {Comment ID}
  2350.              fdPutAway: LongInt;        {Home Dir ID}
  2351.            END;
  2352.  
  2353.   DInfo = RECORD
  2354.             frRect: Rect;       {folder rect}
  2355.             frFlags: INTEGER;   {Flags}
  2356.             frLocation: Point;  {folder location}
  2357.             frView: INTEGER;    {folder view}
  2358.           END;
  2359.  
  2360.   DXInfo = RECORD
  2361.              frScroll: Point;       {scroll position}
  2362.              frOpenChain: LongInt;  {DirID chain of open folders}
  2363.              frUnused: INTEGER;     {unused but reserved}
  2364.              frComment: INTEGER;    {comment}
  2365.              frPutAway: LongInt;    {DirID}
  2366.            END;
  2367.  
  2368.  
  2369.   ParamBlockRec = RECORD
  2370.   {12 byte header used by the file and IO system}
  2371.     qLink: QElemPtr;        {queue link in header}
  2372.     qType: INTEGER;         {type byte for safety check}
  2373.     ioTrap: INTEGER;        {FS: the Trap}
  2374.     ioCmdAddr: Ptr;         {FS: address to dispatch to}
  2375.  
  2376.              {common header to all variants}
  2377.     ioCompletion: ProcPtr; {completion routine addr (0 for
  2378.                             synch calls)}
  2379.     ioResult: OSErr;        {result code}
  2380.     ioNamePtr: StringPtr;   {ptr to Vol:FileName string}
  2381.     ioVRefNum: INTEGER;     {volume refnum (DrvNum for Eject and
  2382.                                 MountVol)}
  2383.  
  2384. {different components for the different type of parameter blocks}
  2385.     CASE ParamBlkType OF
  2386.       IOParam:
  2387.         (ioRefNum: INTEGER;     {refNum for I/O operation}
  2388.          ioVersNum: SignedByte; {version number}
  2389.          ioPermssn: SignedByte; {Open: permissions (byte)}
  2390.  
  2391.          ioMisc: Ptr;           {Rename: new name}
  2392.                                 {GetEOF,SetEOF: logical end of file}
  2393.                                 {Open: optional ptr to buffer}
  2394.                                 {SetFileType: new type}
  2395.          ioBuffer: Ptr;         {data buffer Ptr}
  2396.          ioReqCount: LongInt;   {requested byte count; also =
  2397.                                  ioNewDirID}
  2398.          ioActCount: LongInt;   {actual byte count completed}
  2399.          ioPosMode: INTEGER;    {initial file positioning}
  2400.          ioPosOffset: LongInt); {file position offset}
  2401.  
  2402.       FileParam:
  2403.         (ioFRefNum: INTEGER;        {reference number}
  2404.          ioFVersNum: SignedByte;    {version number}
  2405.          filler1: SignedByte;
  2406.          ioFDirIndex: INTEGER;      {GetFInfo directory index}
  2407.          ioFlAttrib: SignedByte;    {GetFInfo: in-use bit=7, lock
  2408.                                         bit=0}
  2409.          ioFlVersNum: SignedByte;   {file version number}
  2410.          ioFlFndrInfo: FInfo;       {user info}
  2411.          ioFlNum: LongInt;          {GetFInfo: file number; TF-
  2412.                                         ioDirID}
  2413.          ioFlStBlk: INTEGER;        {start file block (0 if none)}
  2414.          ioFlLgLen: LongInt;        {logical length (EOF)}
  2415.          ioFlPyLen: LongInt;        {physical lenght}
  2416.          ioFlRStBlk: INTEGER;       {start block rsrc fork}
  2417.          ioFlRLgLen: LongInt;       {file logical length rsrc fork}
  2418.          ioFlRPyLen: LongInt;       {file physical length rsrc fork}
  2419.          ioFlCrDat: LongInt;        {file creation date & time (32
  2420.                                         bits in secs)}
  2421.          ioFlMdDat: LongInt);       {last modified date and time}
  2422.  
  2423.       VolumeParam:
  2424.         (filler2: LongInt;
  2425.          ioVolIndex: INTEGER;   {volume index number}
  2426.          ioVCrDate: LongInt;    {creation date and time}
  2427.          ioVLsBkUp: LongInt;    {last backup date and time}
  2428.          ioVAtrb: INTEGER;      {volume attrib}
  2429.          ioVNmFls: INTEGER;     {number of files in directory}
  2430.          ioVDirSt: INTEGER;     {start block of file directory}
  2431.          ioVBlLn: INTEGER;      {GetVolInfo: length of dir in
  2432.                                     blocks}
  2433.          ioVNmAlBlks: INTEGER;  {GetVolInfo: num blks (of alloc
  2434.                                     size)}
  2435.          ioVAlBlkSiz: LongInt;  {GetVolInfo: alloc blk byte
  2436.                                     size}
  2437.          ioVClpSiz: LongInt;    {GetVolInfo: bytes to allocate at
  2438.                                     a time}
  2439.          ioAlBlSt: INTEGER;     {starting disk(512-byte) block in
  2440.                                     block map}
  2441.          ioVNxtFNum: LongInt;   {GetVolInfo: next free file
  2442.                                     number}
  2443.          ioVFrBlk: INTEGER);    {GetVolInfo: # free alloc blks
  2444.                                     for this vol}
  2445.  
  2446.       CntrlParam:
  2447.         (ioCRefNum: INTEGER;        {refNum for I/O operation}
  2448.          CSCode: INTEGER;           {word for control status code}
  2449.          CSParam: ARRAY [0..10] OF INTEGER); {operation-defined
  2450.                                                 parameters}
  2451.   END; {ParamBlockRec}
  2452.  
  2453.   ParmBlkPtr = ^ParamBlockRec;
  2454.  
  2455. \ ,146
  2456. 146
  2457. Printing Manager Definitions.
  2458.  
  2459. CONST
  2460.   iPrPgFract = 120; {Page scale factor. ptPgSize (below) is in units of
  2461.                      1/iPrPgFract }
  2462.  
  2463.   iPrPgFst      = 1; {Page range constants}
  2464.   iPrPgMax      = 9999;
  2465.  
  2466.   iPrRelease    = 3; {Current version number of the code.} {DC 7/23/84}
  2467.   iPfMaxPgs     = 128; {Max number of pages in a print file.}
  2468.  
  2469.   {Driver constants}
  2470.   iPrBitsCtl    = 4; {The Bitmap Print Proc's ctl number}
  2471.   lScreenBits   = $00000000; {The Bitmap Print Proc's Screen Bitmap
  2472.                                 param}
  2473.   lPaintBits    = $00000001; {The Bitmap Print Proc's Paint [sq pix]
  2474.                                 param}
  2475.   lHiScreenBits = $00000010; {The Bitmap Print Proc's Screen Bitmap
  2476.                                 param}
  2477.   lHiPaintBits  = $00000011; {The Bitmap Print Proc's Paint [sq pix]
  2478.                                 param}
  2479.   iPrIOCtl      = 5; {The Raw Byte IO Proc's ctl number}
  2480.   iPrEvtCtl     = 6; {The PrEvent Proc's ctl number}
  2481.   lPrEvtAll     = $0002FFFD; {The PrEvent Proc's CParam for the entire
  2482.                                 screen}
  2483.   lPrEvtTop     = $0001FFFD; {The PrEvent Proc's CParam for the top
  2484.                                 folder}
  2485.   iPrDevCtl     = 7;         {The PrDevCtl Proc's ctl number}
  2486.   lPrReset      = $00010000; {The PrDevCtl Proc's CParam for reset}
  2487.   lPrPageEnd    = $00020000; {The PrDevCtl Proc's CParam for end page}
  2488.   lPrLineFeed   = $00030000; {The PrDevCtl Proc's CParam for paper
  2489.                                 advance}
  2490.   lPrLFSixth    = $0003FFFF; {The PrDevCtl Proc's CParam for 1/6 th inch
  2491.                                 paper advance}
  2492.   lPrLFEighth   = $0003FFFE; {The PrDevCtl Proc's CParam for 1/8 th inch
  2493.                                 paper advance}
  2494.   iFMgrCtl      = 8;         {The FMgr's Tail-hook Proc's ctl number}
  2495.   { [The Pre-Hook is the status call] }
  2496.  
  2497.   {Error Constants:}
  2498.   iMemFullErr   = - 108;
  2499.   iPrAbort      = 128;
  2500.   iIOAbort      = - 27;
  2501.  
  2502.   {The PrVars lo mem area:}
  2503.   pPrGlobals    = $00000944;
  2504.   bDraftLoop    = 0;
  2505.   bSpoolLoop    = 1;
  2506.   bUser1Loop    = 2;
  2507.   bUser2Loop    = 3;
  2508.  
  2509.   {The Currently supported printers:}
  2510.   bDevCItoh     = 1;
  2511.   iDevCItoh     = $0100; {CItoh}
  2512.   bDevDaisy     = 2;
  2513.   iDevDaisy     = $0200; {Daisy}
  2514.   bDevLaser     = 3;
  2515.   iDevLaser     = $0300; {Laser}
  2516.  
  2517. TYPE
  2518.   TPRect = ^Rect;       {A Rect Ptr}
  2519.   TPBitMap = ^BitMap;   {A BitMap Ptr}
  2520.  
  2521.   {NOTE: Changes will also affect: PrEqu, TCiVars & TPfVars}
  2522.   TPrVars = RECORD {4 longs for printing, see SysEqu for location.}
  2523.               iPrErr: Integer; {Current print error. Set to iPrAbort to
  2524.                                     abort printing.}
  2525.               bDocLoop: SignedByte; {The Doc style: Draft, Spool, ..,
  2526.                                     and .. Currently use low 2 bits; the
  2527.                                     upper 6 are for flags.}
  2528.               bUser1: SignedByte; {Spares used by the print code}
  2529.               lUser1: LongInt;
  2530.               lUser2: LongInt;
  2531.               lUser3: LongInt;
  2532.             END;
  2533.   TPPrVars = ^TPrVars;
  2534.  
  2535.   TPrInfo = RECORD {Print Info Record: The parameters needed for page
  2536.                     composition.}
  2537.               iDev: Integer; {Font mgr/QuickDraw device code}
  2538.               iVRes: Integer; {Resolution of device, in device
  2539.                                 coordinates}
  2540.               iHRes: Integer; { ..note: V before H => compatable with
  2541.                                 Point.}
  2542.               rPage: Rect; {The page (printable) rectangle in device
  2543.                             coordinates.}
  2544.             END;
  2545.   TPPrInfo = ^TPrInfo;
  2546.  
  2547.   {These are types of paper feeders.}
  2548.   TFeed = (feedCut, feedFanfold, feedMechCut, feedOther);
  2549.  
  2550.   TPrStl = RECORD {Printer Style: The printer configuration and usage
  2551.                    information.}
  2552.              wDev: Integer; {The device (driver) number. Hi byte=RefNum,
  2553.                                 Lo byte=variant. f0 = fHiRes,
  2554.                                 f1 = fPortrait, f2 = fSqPix,
  2555.                                 f3 = f2xZoom, f4 = fScroll.}
  2556.              iPageV: Integer; {paper size in units of 1/iPrPgFract}
  2557.              iPageH: Integer; { ..note: V before H => compatable with
  2558.                                 Point.}
  2559.              bPort: SignedByte; {The IO port number. Refnum?}
  2560.              feed: TFeed; {paper feeder type.}
  2561.            END;
  2562.   TPPrStl = ^TPrStl;
  2563.  
  2564.   {Banding data structures. Not of general interest to Apps.}
  2565.   TScan = {Band Scan direction Top-Bottom, Left-Right, etc.}
  2566.   (scanTB, scanBT, scanLR, scanRL);
  2567.  
  2568.   TPrXInfo = RECORD {The print time eXtra information.}
  2569.                iRowBytes: Integer; {The Band's rowBytes.}
  2570.                iBandV: Integer; {Size of band, in device coordinates}
  2571.                iBandH: Integer; { ..note: V before H => compatible with
  2572.                                  Point.}
  2573.                iDevBytes: Integer; {Size for allocation. May be more
  2574.                                     than rBounds size!}
  2575.                iBands: Integer; {Number of bands per page.}
  2576.  
  2577.                bPatScale: SignedByte; {Pattern scaling}
  2578.                bULThick: SignedByte; {3 Underscoring parameters}
  2579.                bULOffset: SignedByte;
  2580.                bULShadow: SignedByte;
  2581.  
  2582.                scan: TScan; {Band scan direction}
  2583.                bXInfoX: SignedByte; {An eXtra byte.}
  2584.              END;
  2585.   TPPrXInfo = ^TPrXInfo;
  2586.  
  2587.   TPrJob = RECORD {Print Job: Print "form" for a single print request.}
  2588.              iFstPage: Integer; {Page Range.}
  2589.              iLstPage: Integer;
  2590.              iCopies: Integer; {No. copies.}
  2591.              bJDocLoop: SignedByte; {The Doc style: Draft, Spool, ..,
  2592.                                         and ..}
  2593.              fFromUsr: Boolean; {Printing from an User's App (not PrApp)
  2594.                                     flag}
  2595.              pIdleProc: ProcPtr; {The Proc called while waiting on IO
  2596.                                     etc.}
  2597.              pFileName: StringPtr; {Spool File Name: NIL for default.}
  2598.              iFileVol: Integer; {Spool File vol, set to 0 initially}
  2599.              bFileVers: SignedByte; {Spool File version, set to 0
  2600.                                         initially}
  2601.              bJobX: SignedByte; {An eXtra byte.}
  2602.            END;
  2603.   TPPrJob = ^TPrJob;
  2604.  
  2605.   TPrint = RECORD {The universal 120 byte printing record}
  2606.              iPrVersion: Integer; {2} {Printing software version}
  2607.              PrInfo: TPrInfo; {14} {the PrInfo data associated with the
  2608.                                     current style.}
  2609.              rPaper: Rect; {8} {The paper rectangle [offset from rPage]}
  2610.              PrStl: TPrStl; {8} {This print request's style.}
  2611.              PrInfoPT: TPrInfo; {14} {Print Time Imaging metrics}
  2612.              PrXInfo: TPrXInfo; {16} {Print-time (expanded) Print info
  2613.                                       record.}
  2614.              PrJob: TPrJob; {20} {The Print Job request}
  2615.                   {82} {Total of the above; 120-82 = 38 bytes needed to
  2616.                         fill 120}
  2617.              PrintX: ARRAY [1..19] OF Integer; {Spare to fill to 120
  2618.                                                 bytes!}
  2619.            END;
  2620.   TPPrint = ^TPrint;
  2621.   THPrint = ^TPPrint;
  2622.  
  2623. {Printing Graf Port. All printer imaging, whether spooling, banding, etc, happens "thru" a GrafPort.}
  2624.   TPrPort = RECORD {This is the "PrPeek" record.}
  2625.               GPort: GrafPort; {The Printer's graf port.}
  2626.               GProcs: QDProcs; {..and its procs}
  2627.  
  2628.               lGParam1: LongInt; {16 bytes for private parameter storage.}
  2629.               lGParam2: LongInt;
  2630.               lGParam3: LongInt;
  2631.               lGParam4: LongInt;
  2632.  
  2633.               fOurPtr: Boolean; {Whether the PrPort allocation was done by
  2634.                                  us.}
  2635.               fOurBits: Boolean; {Whether the BitMap allocation was done by
  2636.                                   us.}
  2637.             END;
  2638.   TPPrPort = ^TPrPort;
  2639.  
  2640.   TPrStatus = RECORD {Print Status: Print information during printing.}
  2641.                 iTotPages: Integer; {Total pages in Print File.}
  2642.                 iCurPage: Integer; {Current page number}
  2643.                 iTotCopies: Integer; {Total copies requested}
  2644.                 iCurCopy: Integer; {Current copy number}
  2645.                 iTotBands: Integer; {Total bands per page.}
  2646.                 iCurBand: Integer; {Current band number}
  2647.                 fPgDirty: Boolean; {True if current page has been written to.}
  2648.                 fImaging: Boolean; {Set while in band's DrawPic call.}
  2649.                 hPrint: THPrint; {Handle to the active Printer record}
  2650.                 pPrPort: TPPrPort; {Ptr to the active PrPort}
  2651.                 hPic: PicHandle; {Handle to the active Picture}
  2652.               END;
  2653.   TPPrStatus = ^TPrStatus;
  2654.  
  2655. {PicFile = a TPfHeader followed by n QuickDraw Pics (whose PicSize is invalid!)}
  2656.   TPfPgDir = RECORD
  2657.                iPages: Integer;
  2658.                lPgPos: ARRAY [0..iPfMaxPgs] OF LongInt;
  2659.              END;
  2660.   TPPfPgDir = ^TPfPgDir;
  2661.   THPfPgDir = ^TPPfPgDir;
  2662.  
  2663.   TPfHeader = RECORD {Print File header.}
  2664.                 Print: TPrint;
  2665.                 PfPgDir: TPfPgDir;
  2666.               END;
  2667.   TPPfHeader = ^TPfHeader;
  2668.   THPfHeader = ^TPPfHeader; {Note: Type compatable with an hPrint.}
  2669.  
  2670. { This is the Printing Dialog Record. Only used by folks appending their own dialogs. }
  2671.   TPrDlg = RECORD {Print Dialog: The Dialog Stream object.}
  2672.              Dlg: DialogRecord; {The Dialog window}
  2673.              pFltrProc: ProcPtr; {The Filter Proc.}
  2674.              pItemProc: ProcPtr; {The Item evaluating proc.}
  2675.              hPrintUsr: THPrint; {The user's print record.}
  2676.              fDoIt: Boolean;
  2677.              fDone: Boolean;
  2678.              lUser1: LongInt; {Four longs for user's to hang global data.}
  2679.              lUser2: LongInt;
  2680.              lUser3: LongInt;
  2681.              lUser4: LongInt;
  2682.               {  ...Plus more stuff needed by the particular printing dialog.}
  2683.            END;
  2684.   TPPrDlg = ^TPrDlg; {== a dialog ptr}
  2685. \ ,147
  2686. 147
  2687. Device Manager Definitions.
  2688.  
  2689. \ ,148
  2690. 148
  2691. Disk Driver Definitions.
  2692.  
  2693. \ ,149
  2694. 149
  2695. Sound Driver Definitions.
  2696. \ ,151
  2697. 151
  2698. AppleTalk definitions.
  2699.  
  2700. CONST
  2701.  
  2702.   lapSize = 20;
  2703.   ddpSize = 26;
  2704.   nbpSize = 26;
  2705.   atpSize = 56;
  2706.  
  2707.   {error codes}
  2708.  
  2709.   ddpSktErr = - 91;
  2710.   ddpLenErr = - 92;
  2711.   noBridgeErr = - 93;
  2712.   LAPProtErr = - 94;
  2713.   excessCollsns = - 95;
  2714.  
  2715.   nbpBuffOvr = - 1024;
  2716.   nbpNoConfirm = - 1025;
  2717.   nbpConfDiff = - 1026;
  2718.   nbpDuplicate = - 1027;
  2719.   nbpNotFound = - 1028;
  2720.   nbpNISErr = - 1029;
  2721.  
  2722.   reqFailed = - 1096;
  2723.   tooManyReqs = - 1097;
  2724.   tooManySkts = - 1098;
  2725.   badATPSkt = - 1099;
  2726.   badBuffNum = - 1100;
  2727.   noRelErr = - 1101;
  2728.   cbNotFound = - 1102;
  2729.   noSendResp = - 1103;
  2730.   noDataArea = - 1104;
  2731.   reqAborted = - 1105;
  2732.  
  2733.   buf2SmallErr = - 3101;
  2734.   noMPPErr = - 3102;
  2735.   ckSumErr = - 3103;
  2736.   extractErr = - 3104;
  2737.   readQErr = - 3105;
  2738.   atpLenErr = - 3106;
  2739.   atpBadRsp = - 3107;
  2740.   recNotFnd = - 3108;
  2741.   sktClosedErr = - 3109;
  2742.  
  2743. TYPE
  2744.  
  2745.   ABByte = 1..127;
  2746.  
  2747.   STR32 = STRING[32];
  2748.  
  2749.   ABCallType = (tLAPRead, tLAPWrite, tDDPRead, tDDPWrite, tNBPLookUp,
  2750.     tNBPConfirm, tNBPRegister, tATPSndRequest, tATPGetRequest,
  2751.     tATPSdRsp, tATPAddRsp, tATPRequest, tATPResponse);
  2752.  
  2753.   ABProtoType = (lapProto, ddpProto, nbpProto, atpProto);
  2754.  
  2755.   LAPAdrBlock = PACKED RECORD
  2756.       dstNodeID: Byte;
  2757.       srcNodeID: Byte;
  2758.       LAPProtType: ABByte;
  2759.     END;
  2760.  
  2761.   AddrBlock = PACKED RECORD
  2762.     aNet: INTEGER;
  2763.     aNode: Byte;
  2764.     aSocket: Byte;
  2765.      END;
  2766.  
  2767.   EntityName = RECORD
  2768.      objStr: STR32;
  2769.      typeStr: STR32;
  2770.      zoneStr: STR32;
  2771.       END;
  2772.  
  2773.   EntityPtr = ^EntityName;
  2774.  
  2775.   RetransType = PACKED RECORD
  2776.       retransInterval: Byte;
  2777.       retransCount: Byte;
  2778.     END;
  2779.  
  2780.   BitMapType = PACKED ARRAY [0..7] OF BOOLEAN;
  2781.  
  2782.   BDSElement = RECORD
  2783.      BuffSize: INTEGER;
  2784.      BuffPtr: Ptr;
  2785.      DataSize: INTEGER;
  2786.      UserBytes: LongInt;
  2787.       END;
  2788.  
  2789.   BDSType = ARRAY [0..7] OF BDSElement;
  2790.  
  2791.   BDSPtr = ^BDSType;
  2792.  
  2793.   ABusRecord = RECORD
  2794.      abOpCode: ABCallType;
  2795.      abResult: INTEGER;
  2796.      abUserReference: LongInt;
  2797.  
  2798.      CASE ABProtoType OF
  2799.        lapProto:
  2800.       (lapAddress: LAPAdrBlock;
  2801.        lapReqCount: INTEGER;
  2802.        lapActCount: INTEGER;
  2803.        lapDataPtr: Ptr; );
  2804.  
  2805.        ddpProto:
  2806.       (ddpType: Byte;
  2807.        ddpSocket: Byte;
  2808.        ddpAddress: AddrBlock;
  2809.        ddpReqCount: INTEGER;
  2810.        ddpActCount: INTEGER;
  2811.        ddpDataPtr: Ptr;
  2812.        ddpNodeID: Byte; );
  2813.  
  2814.        nbpProto:
  2815.       (nbpEntityPtr: EntityPtr;
  2816.        nbpBufPtr: Ptr;
  2817.        nbpBufSize: INTEGER;
  2818.        nbpDataField: INTEGER;
  2819.        nbpAddress: AddrBlock;
  2820.        nbpRetransmitInfo: RetransType; );
  2821.  
  2822.        atpProto:
  2823.  
  2824.       (atpSocket: Byte;
  2825.        atpAddress: AddrBlock;
  2826.        atpReqCount: INTEGER;
  2827.        atpDataPtr: Ptr;
  2828.        atpRspBDSPtr: BDSPtr;
  2829.        atpBitMap: BitMapType;
  2830.        atpTransID: INTEGER;
  2831.        atpActCount: INTEGER;
  2832.        atpUserData: LongInt;
  2833.        atpXO: BOOLEAN;
  2834.        atpEOM: BOOLEAN;
  2835.        atpTimeOut: Byte;
  2836.        atpRetries: Byte;
  2837.        atpNumBufs: Byte;
  2838.        atpNumRsp: Byte;
  2839.        atpBDSSize: Byte;
  2840.  
  2841.        atpRspUData: LongInt;
  2842.        atpRspBuf: Ptr;
  2843.        atpRspSize: INTEGER; );
  2844.  
  2845.       END; {record}
  2846.  
  2847.   ABRecPtr = ^ABusRecord;
  2848.   ABRecHandle = ^ABRecPtr;
  2849. \,152
  2850. 152
  2851. Interface for Vertical Retrace Manager
  2852.  
  2853. TYPE
  2854.   VBLTask = Record
  2855.              qLink:    QElemPtr;   {next queue entry}
  2856.              qType:    Integer;    {queue type}
  2857.              vnlAddr:  ProcPtr;    {pointer to task}
  2858.              vblCount: Integer;    {task frequency}
  2859.              vblPhase: Integer;    {task phase}
  2860.            End;
  2861.  
  2862.  
  2863. jDoVBLTask  Jump vector for DoVBLTask routine
  2864. \,153
  2865. 153
  2866. Interface for OS Utilities
  2867.  
  2868. CONST   { Addressing modes }
  2869.  
  2870.       false32b = 0;  {24-bit addressing mode}
  2871.       true32b  = 1;  {32-bit addressing mode}
  2872.  
  2873.  
  2874.  
  2875. false32b    EQU 0   ;24-bit addressing mode
  2876. true32b     EQU 1   ;32-bit addressing mode
  2877.  
  2878. Variables
  2879.  
  2880. MMU32Bit    Current address mode (byte)
  2881. \ ,154
  2882. 154
  2883. List Manager Definitions.
  2884.  
  2885. CONST
  2886.  
  2887. { Masks for selection flags (selFlags) }
  2888.  
  2889.     LOnlyOne = -128;        { 0 = multiple selections, 1 = one }
  2890.     LExtendDrag = 64;       { 1 = drag select without shift key }
  2891.     LNoDisjoint = 32;       { 1 = turn off selections on click }
  2892.     LNoExtend = 16;         { 1 = don't extend shift selections }
  2893.     LNoRect = 8;            { 1 = don't grow (shift,drag) selection as
  2894.                                 rect }
  2895.     LUseSense = 4;          { 1 = shift should use sense of start cell }
  2896.     LNoNilHilite = 2;       { 1 = don't hilite empty cells }
  2897.  
  2898. { Masks for other flags (listFlags) }
  2899.  
  2900.     LDoVAutoscroll = 2;     { 1 = allow vertical autoscrolling }
  2901.     LDoHAutoscroll = 1;     { 1 = allow horizontal autoscrolling }
  2902.  
  2903. { Messages to list definition procedure }
  2904.  
  2905.     LInitMsg = 0;           { tell drawing routines to init themselves }
  2906.     LDrawMsg = 1;           { draw (and de/select) the indicated data }
  2907.     LHiliteMsg = 2;         { invert hilite state of specified cell }
  2908.     LCloseMsg = 3;          { shut down, the list is being disposed }
  2909.  
  2910. TYPE
  2911.  
  2912.     Cell = Point;
  2913.  
  2914.     dataArray  = PACKED ARRAY[0..32000] OF Char;
  2915.     dataPtr    = ^dataArray;
  2916.     dataHandle = ^dataPtr;
  2917.  
  2918.     ListPtr    = ^ListRec;
  2919.     ListHandle = ^ListPtr;
  2920.     ListRec    = RECORD
  2921.             rView : Rect;               {Rect in which we are viewed}
  2922.             port : GrafPtr;             {Grafport that owns us}
  2923.             indent : Point;             {Indent pixels in cell}
  2924.             cellSize : Point;           {Cell size}
  2925.             visible : Rect;             {visible row/column bounds}
  2926.             vScroll : ControlHandle;    {vertical scroll bar (or NIL)}
  2927.             hScroll : ControlHandle;    {horizontal scroll bar (or NIL)}
  2928.             selFlags : SignedByte;      { defines selection characteristics
  2929.             LActive : Boolean;          { active or not }
  2930.             LReserved : SignedByte;     { internally used flags }
  2931.             listFlags : SignedByte;     { other flags }
  2932.             clikTime : Longint;         { save time of last click }
  2933.             clikLoc : Point;            { save position of last click }
  2934.             mouseLoc : Point;           { current mouse position }
  2935.             LClikLoop : Ptr;            { routine called repeatedly during
  2936.                                         ListClick }
  2937.             lastClick : Cell;           { the last cell clicked in }
  2938.             refCon : Longint;           { reference value }
  2939.             listDefProc : Handle;       { Handle to the defProc }
  2940.             userHandle : Handle;        { General purpose handle for user}
  2941.             dataBounds : Rect;          { Total number of rows/columns}
  2942.             cells : dataHandle;         { Handle to data}
  2943.             maxIndex : Integer;         { index past the last element}
  2944.             cellArray : ARRAY[1..1] OF Integer;     { offsets to elements }
  2945.         END;
  2946. \,155
  2947. 155
  2948.  
  2949. Pseudo devices for the macintosh :
  2950.  
  2951.  'Printer:' for printer, write-only.
  2952.  'Modem:' for modem at 300 bauds, read-write.
  2953.  'Keyboard:' for keyboard, read-only.
  2954. \,159
  2955. 159
  2956. Interfaces For Apple Desktop Bus
  2957.  
  2958. TYPE
  2959.  
  2960.   ADBDataBlock = PACKED RECORD
  2961.     devType: SignedByte;        {device type}
  2962.     origADBAddr: SignedByte;    {original ADB address}
  2963.     dbServiceRtPtr: Ptr;        {service routine  address}
  2964.     dbDataAreaAddr: Ptr         {data area address}
  2965.   END;
  2966.  
  2967.   ADBSetInfoBlock = RECORD
  2968.     siServiceRtPtr: Ptr;    {service routine address}
  2969.     siDataAreaAddr: Ptr {data area address}
  2970.   END;
  2971. \,160
  2972. 160
  2973. Interface for Cursor Control (ctl) manager
  2974.  
  2975. TYPE
  2976.  
  2977. { Kinds of cursor supported by CursorCtl }
  2978. Cursors = (HIDDEN_CURSOR,I_BEAM_CURSOR,CROSS_CURSOR,PLUS_CURSOR,WATCH_CURSOR,
  2979.     ARROW_CURSOR);
  2980.  
  2981. acurPtr = ^Acur;
  2982. acurHandle = ^acurPtr;
  2983. Acur = RECORD
  2984.     n: INTEGER;         {Number of cursors ("frames of film")}
  2985.     index: INTEGER;     { Next frame to show <for internal use>}
  2986.     frame1: INTEGER;    {'CURS' resource id for frame #1}
  2987.     fill1: INTEGER;     {<for internal use>}
  2988.     frame2: INTEGER;    {'CURS' resource id for frame #2}
  2989.     fill2: INTEGER;     {<for internal use>}
  2990.     frameN: INTEGER;    {'CURS' resource id for frame #N}
  2991.     fillN: INTEGER;     {<for internal use>}
  2992.     END;
  2993.  
  2994. \,165
  2995. 165
  2996. Interface for Palette Manager
  2997.  
  2998. CONST { Usage constants }
  2999.  
  3000.     pmCourteous = $0000;
  3001.     pmDithered = $0001; {not implemented}
  3002.     pmTolerant = $0002;
  3003.     pmAnimated = $0004;
  3004.     pmExplicit = $0008;
  3005. Data Types
  3006. TYPE
  3007.   ColorInfo = RECORD
  3008.         ciRGB:  RGBColor;       {absolute RGB values}
  3009.         ciUsage: INTEGER        {color usage information}
  3010.         ciTolerance: INTEGER;   {tolerance value}
  3011.         ciFlags: INTEGER;       {private field}
  3012.         ciPrivate: LONGINT;     {private field}
  3013.     END;
  3014.    PaletteHandle = ^PalettePtr;
  3015.    PalettePtr    = ^Palette;
  3016.    Palette = RECORD
  3017.     pmEntries: integer;                     {entries in pmInfo}
  3018.     pmDataFields: array [0..6] of integer;  {private fields}
  3019.     pmInfo: array [0..0] of ColorInfo;
  3020.    END;
  3021.  
  3022.  
  3023. Assembly Language Information
  3024.  
  3025. pmCourteous EQU $0000   ;courteous colors
  3026. pmDithered  EQU $0001   ;reserved for future use
  3027. pmTolerant  EQU $0002   ;tolerant colors
  3028. pmAnimated  EQU $0004   ;animating colors
  3029. pmExplicit  EQU $0008   ;explicit colors
  3030.  
  3031.  
  3032. ; ColorInfo structure
  3033. ciRGB       EQU $0000   ;absolute RGB values
  3034. ciUsage     EQU $0006   ;color usage information
  3035. ciTolerance EQU $0008   ;tolerance value
  3036. ciFlags     EQU $000A   ;private field
  3037. ciPrivate   EQU $000C   ;private
  3038. ciSize      EQU $0010   ;size of the ColorInfo data structure
  3039.  
  3040. ; Palette structure
  3041. pmEntries   EQU $0000   ;entries in pmInfo
  3042. pmInfo      EQU $0010   ;color info
  3043. pmHdrSize   EQU $0010   ;size of Palette header
  3044. \,167
  3045. 167
  3046. Interface for Color Picker
  3047.  
  3048. CONST
  3049.     MaxSmallFract   = $0000FFFF;    {maximum SmallFract value, as LONGINT}
  3050.  
  3051. TYPE
  3052.     SmallFract  = INTEGER;   {unsigned fraction between 0 and 1}
  3053.  
  3054.     HSVColor = RECORD
  3055.             hue:    SmallFract; {fraction of circle, red at 0}
  3056.             saturation: SmallFract; {0-1, 0 is gray, 1 is pure color}
  3057.             value:  SmallFract; {0-1, 0 is black, 1 is max }
  3058.           END;
  3059.  
  3060.     HSLColor = RECORD
  3061.             hue: SmallFract;            {fraction of circle, red at 0}
  3062.             saturation: SmallFract;     {0-1, 0 is gray, 1 is pure color}
  3063.             lightness: SmallFract;      {0-1, 0 is black, 1 is white}
  3064.         END;
  3065.  
  3066.     CMYColor = RECORD    {CMY and RGB are complements}
  3067.             cyan: SmallFract;
  3068.             magenta: SmallFract;
  3069.             yellow: SmallFract;
  3070.         END;
  3071.  
  3072. Constants
  3073. Fix2SmallFract  EQU 1
  3074. SmallFract2Fix  EQU 2
  3075. CMY2RGB         EQU 3
  3076. RGB2CMY         EQU 4
  3077. HSL2RGB         EQU 5
  3078. RGB2HSL         EQU 6
  3079. HSV2RGB         EQU 7
  3080. RGB2HSV         EQU 8
  3081. GetColor        EQU 9
  3082. \,170
  3083. 170
  3084. Interface for Color Manager
  3085.  
  3086. CONST
  3087.     minSeed = 1023; {minimum seed value for ctSeed}
  3088.  
  3089.  
  3090. TYPE
  3091.    ITabHandle = ^ITabPtr;
  3092.    ITabPtr    = ^ITab;
  3093.    ITab       = RECORD
  3094.         iTabSeed:   LONGINT;    {copy of color table seed}
  3095.         iTabRes:    INTEGER;    {resolution of table}
  3096.         iTTable:    ARRAY[0..0] OF SignedByte   {byte color }
  3097.                     { table index values}
  3098.                 END;
  3099.    SProcHndl   = ^SProcPtr;
  3100.    SProcPtr    = ^SProcRec;;
  3101.    SProcRec    = RECORD
  3102.         nxtSrch:    SProcHndl;  {handle to next sProcRec}
  3103.         srchProc:   ProcPtr {pointer to search }
  3104.                 { procedure}
  3105.                  END;
  3106.    CProcHndl   = ^CProcPtr;
  3107.    CProcPtr    = ^CProcRec;
  3108.    CProcRec    = RECORD
  3109.         nxtComp:    CProcHandle;    {pointer to next }
  3110.                 { CProcRec}
  3111.         compProc:   ProcPtr {pointer to complement }
  3112.                 { procedure}
  3113.                  END;
  3114.    ReqListRec = RECORD
  3115.         reqLSize:   INTEGER;    {request list size –1}
  3116.         reqLData:   ARRAY [0..0] of INTEGER {request list }
  3117.                     { data}
  3118.                 END;
  3119.  
  3120.  
  3121.  
  3122. Constants
  3123. minSeed     EQU 1023    ;minimum ctSeed value
  3124.  
  3125. ITab structure
  3126. iTabSeed    EQU $0      ;[long] ID of owning color table
  3127. iTabRes     EQU $4      ;[word] client ID
  3128. iTTable     EQU $6      ;table of indices starts here
  3129.                         ;in this version, entries are BYTE
  3130.  
  3131. SProcRec structure
  3132. nxtSrch     EQU $0      ;[pointer] link to next proc
  3133. srchProc    EQU $4      ;[pointer] pointer to routine
  3134.  
  3135. CProcRec structure
  3136. nxtComp     EQU $0      ;[pointer] link to next proc
  3137. compProc    EQU $4      ;[pointer] pointer to routine
  3138.  
  3139. Request list structure
  3140. reqLSize    EQU 0       ;[word] request list size –1
  3141. reqLData    EQU 2       ;[word] request list data
  3142. \,171
  3143. 171
  3144. Interface to build a cdev
  3145.  
  3146. CONST
  3147.  
  3148. { messages }
  3149.     initDev     = 0;    {initialization}
  3150.     hitDev      = 1;    {user clicked on dialog item}
  3151.     closeDev    = 2;    {user selected another cdev or CP closed}
  3152.     nulDev      = 3;    {desk accessory run}
  3153.     updateDev   = 4;    {update event}
  3154.     activDev    = 5;    {activate event}
  3155.     deActivDev  = 6;    {deactivate event}
  3156.     keyEvtDev   = 7;    {key down or autokey event}
  3157.     macDev      = 8;    {check machine characteristics}
  3158.     undoDev     = 9;    {standard Edit menu undo}
  3159.     cutDev      =10;    {standard Edit menu cut}
  3160.     copyDev     =11;    {standard Edit menu copy}
  3161.     pasteDev    =12;    {standard Edit menu paste}
  3162.     clearDev    =13;    {standard Edit menu clear}
  3163.  
  3164. { Special cdevValue values }
  3165.     cdevGenErr  = -1;   {general error; gray cdev w/o alert}
  3166.     cdevMemErr  =  0;   {memory shortfall; alert user please}
  3167.     cdevResErr  =  1;   {couldn't get a needed resource; alert}
  3168.     cdevUnset   =  3;   {cdevValue is initialized to this}
  3169. \,172
  3170. 172
  3171. Interface for Graphics Devices
  3172.  
  3173. Constants
  3174. { Values for GDFlags }
  3175. clutType    = 0;    {0 if lookup table}
  3176. fixedType   = 1;    {1 if fixed table}
  3177. directType  = 2;    {2 if direct values}
  3178.  
  3179. { Bit assignments for GDFlags }
  3180. gdDevType   = 0;    {0 = monochrome, 1 = color}
  3181. ramInit     = 10;   {set if device has been initialized from RAM}
  3182. mainScreen  = 11;   {set if device is main screen}
  3183. allInit     = 12;   {set if devices were initialized from a 'scrn' }
  3184.                     { resource}
  3185. screenDevice= 13;   {set if device is a screen device}
  3186. noDriver    = 14;   {set if device has no driver}
  3187. screenActive= 15;   {set if device is active}
  3188.  
  3189. Data Types
  3190. TYPE
  3191.    GDHandle   = ^GDPtr;
  3192.    GDPtr      = ^GDevice;
  3193.    GDevice    = RECORD
  3194.     gdRefNum:   INTEGER;    {reference number of driver}
  3195.     gdID:   INTEGER;        {client ID for search procedure}
  3196.     gdType: INTEGER;        {device type}
  3197.     gdITable:   ITabHandle; {inverse table}
  3198.     gdResPref:  INTEGER;    {preferred resolution}
  3199.     gdSearchProc:   SProcHndl;  {list of search procedures}
  3200.     gdCompProc: CProcHndl;  {list of complement procedures}
  3201.     gdFlags:    INTEGER;    {grafDevice flags word}
  3202.     gdPMap: PixMapHandle;   {pixel map for displayed image}
  3203.     gdRefCon:   LONGINT;    {reference value}
  3204.     gdNextGD:   GDHandle;   {handle of next gDevice}
  3205.     gdRect: Rect;           {device's global bounds}
  3206.     gdMode: LONGINT;        {device's current mode}
  3207.     gdCCBytes:  INTEGER;    {rowBytes of expanded cursor data}
  3208.     gdCCDepth:  INTEGER;    {depth of expanded cursor data}
  3209.     gdCCXData:  Handle;     {handle to cursor's expanded data}
  3210.     gdCCXMask:  Handle;     {handle to cursor's expanded mask}
  3211.     gdReserved: LONGINT     {reserved for future expansion}
  3212.    END;
  3213.  
  3214. Global Variables
  3215. DeviceList  {handle to the first element in the device list}
  3216. GrayRgn     {contains size and shape of current desktop}
  3217. TheGDevice  {handle to current active device}
  3218. MainDevice  {handle to the current main device}
  3219.  
  3220. Values for GDTypes
  3221. clutType    EQU 0   ;0 if lookup table
  3222. fixedType   EQU 1   ;1 if fixed table
  3223. directType  EQU 2   ;2 if direct values
  3224.  
  3225. Bit Assignments for GDFlags
  3226. gdDevType   EQU 0       ;0 = monochrome, 1 = color
  3227. ramInit     EQU 10      ;set if device has been initialized from RAM
  3228. mainScreen  EQU 11      ;set if device is main screen
  3229. allInit     EQU 12      ;set if devices were initialized from a
  3230.                         ; 'scrn' resource
  3231. screenDevice EQU 13     ;set if device is a screen device
  3232. noDriver    EQU  14     ;set if device has no driver
  3233. screenActive EQU 15     ;set if device is active GDevice field offsets
  3234. gdRefNum    EQU $0      ;[word] unitNum of driver
  3235. gdID        EQU $2      ;[word] client ID for search procs
  3236. gdType      EQU $4      ;[word] fixed/CLUT/direct
  3237. gdITable    EQU $6      ;[long] handle to inverse table
  3238. gdResPref   EQU $A      ;[word] preferred resolution for inverse tables
  3239. gdSearchProc EQU $C     ;[long] search proc (list?) pointer
  3240. gdCompProc  EQU $10     ;[long] complement proc (list?) pointer
  3241. gdFlags     EQU $14     ;[word] grafDevice flags word
  3242. gdPMap      EQU $16     ;[long] handle to pixMap describing device
  3243. gdRefCon    EQU $1A     ;[long] reference value
  3244. gdNextGD    EQU $1E     ;handle of next gDevice
  3245. gdRect      EQU $22     ;device's global bounds
  3246. gdMode      EQU $2A     ;device's current mode
  3247. gdCCBytes   EQU $2E     ;rowBytes of expanded cursor data
  3248. gdCCDepth   EQU $30     ;handle to cursor’s expanded data
  3249. gdCCXData   EQU $32     ;depth of expanded cursor data
  3250. gdCCXMask   EQU $36     ;handle to cursor's expanded mask
  3251. gdReserved  EQU $3A     ;[long] MUST BE 0
  3252. gdRec       EQU $3E     ;size of GrafDevice record
  3253.  
  3254. Global Variables
  3255.  
  3256. DeviceList  EQU $8A8    ;handle to the first element in the device list
  3257. GrayRgn EQU $9EE        ;contains size and shape of current desktop
  3258. TheGDevice  EQU $CC8    ;handle to current active device
  3259. MainDevice  EQU $8A4    ;handle to the current main device
  3260. \,173
  3261. 173
  3262. Interface for Shutdown Manager
  3263.  
  3264. CONST   { Masks for ShutDwnInstall procedure }
  3265.  
  3266.       sdOnPowerOff  = 1;    {call procedure before power off}
  3267.       sdOnRestart   = 2;    {call procedure before restart}
  3268.       sdOnUnmount   = 4;    {call procedure before unmounting}
  3269.       sdOnDrivers   = 8;    {call procedure before closing drivers}
  3270.       sdRestartOrPower  = sdOnPowerOff + sdOnRestart {call procedure}
  3271.                             { before either power off or restart}
  3272.  
  3273. Assembly-Language Information
  3274. Constants
  3275.  
  3276. ; Masks for ShutDwnInstall procedure
  3277.  
  3278. sdOnPowerOff    EQU 1   ;call procedure before power off
  3279. sdOnRestart     EQU 2   ;call procedure before restart
  3280. sdOnUnmount     EQU 4   ;call procedure before unmounting
  3281. sdOnDrivers     EQU 8   ;call procedure before closing drivers
  3282. sdRestartOrPower EQU sdOnPowerOff + sdOnRestart
  3283.  
  3284. ; Routine selectors
  3285. ; (Note:  You can invoke each of the Shutdown Manager routines with
  3286. ; a macro that has the same name as the routine preceded by an
  3287. ; underscore.)
  3288.  
  3289. sdPowerOff  .EQU    1
  3290. sdRestart   .EQU    2
  3291. sdInstall   .EQU    3
  3292. sdRemove    .EQU    4
  3293.  
  3294. Trap Macro Name
  3295.  
  3296. _Shutdown
  3297.  
  3298. (Note:  You can invoke each of the Shutdown Manager routines with a macro that has the same name as the routine preceded by an underscore.  Also, be aware that the _Shutdown macro is not in ROM.)
  3299. \,175
  3300. 175
  3301. Interface for Sound Manager
  3302.  
  3303. CONST   { Command numbers for SndDoCommand }
  3304.  
  3305.     nullCmd     = 0;
  3306.     initCmd     = 1;
  3307.     freeCmd     = 2;
  3308.     quietCmd    = 3;
  3309.     flushCmd    = 4;
  3310.     waitCmd     = 10;
  3311.     pauseCmd    = 11;
  3312.     resumeCmd   = 12;
  3313.     callBackCmd = 13;
  3314.     syncCmd     = 14;
  3315.     emptyCmd    = 15;
  3316.     tickleCmd   = 20;
  3317.     requestNextCmd = 21;
  3318.     howOftenCmd = 22;
  3319.     wakeUpCmd   = 23;
  3320.     availableCmd = 24;
  3321.     noteCmd     = 40;
  3322.     restCmd     = 41;
  3323.     freqCmd     = 42;
  3324.     ampCmd      = 43;
  3325.     timbreCmd   = 44;
  3326.     waveTableCmd = 60;
  3327.     phaseCmd    = 61;
  3328.     soundCmd    = 80;
  3329.     bufferCmd   = 81;
  3330.     rateCmd     = 82;
  3331.     midiDataCmd = 100;
  3332.  
  3333.     { Synthesizer numbers for SndNewChannel }
  3334.  
  3335.     noteSynth       = 1;    {note synthesizer}
  3336.     waveTableSynth  = 3;    {wave table synthesizer}
  3337.     sampledSynth    = 5;    {sampled sound synthesizer}
  3338.     MIDISynthIn     = 7;    {MIDI synthesizer in}
  3339.     MIDISynthOut    = 9;    {MIDI synthesizer out}
  3340.  
  3341.     { Param2 values }
  3342.  
  3343.     MidiInitChannel     = n;    {MIDI Channel to init $0 .. $F}
  3344.     MidiInitChanFilter  = $10;  {set to initialize a MIDI Channel}
  3345.     MidiInitRawMode     = $100; {set to send raw MIDI data}
  3346.  
  3347.     { Queue length }
  3348.  
  3349.     StdQLength      = 128       {standard queue length}
  3350.  
  3351.  
  3352. Data Types
  3353. TYPE SndCommand =   PACKED RECORD
  3354.     cmd:    INTEGER;    {command number}
  3355.     param1: INTEGER;    {first parameter}
  3356.     param2: LONGINT;    {second parameter}
  3357.   END;
  3358.  
  3359. Time =  LONGINT;
  3360.  
  3361. SndChannel =    RECORD
  3362.     nextChan: SndChannelPtr;    {pointer to next channel}
  3363.     firstMod: ModifierStubPtr;  {pointer to first modifier}
  3364.     callBack: ProcPtr;          {pointer to channel's  call back
  3365.                                  procedure}
  3366.     userInfo: LONGINT;          {free for use}
  3367.     wait: Time;                 {used internally}
  3368.     cmdInProg: SndCommand;      {used internally}
  3369.     flags: INTEGER;             {used internally}
  3370.     qLength: INTEGER;           {queue length}
  3371.     qHead: INTEGER;             {used internally}
  3372.     qTail: INTEGER;             {used internally}
  3373.     queue: ARRAY[0..stdQLength-1] OF SndCommand
  3374.   END;
  3375.  
  3376. ModifierStub =  RECORD
  3377.     nextStub: ModifierStubPtr;  {pointer to next modifier}
  3378.     code: ProcPtr;              {pointer to modifier code}
  3379.     userInfo: LONGINT;          {free for modifier to use}
  3380.     count: Time;                {used internally}
  3381.     every: Time;                {used internally}
  3382.     flags: SignedByte;          {used internally}
  3383.     hState: SignedByte          {used internally}
  3384.   END;
  3385.  
  3386. Result Codes
  3387. Name            Value   Meaning
  3388.  
  3389. badChannel      –205    Invalid channel queue length
  3390. badFormat       –206    Handle to 'snd ' resource was invalid
  3391. noHardware      –200    No hardware support for the specified synthesizer
  3392. notEnoughHardware –201  No more channels for the specified synthesizer
  3393. queueFull       –203    No room in the queue
  3394. resProblem      –204    Problem loading the resource
  3395. \,176
  3396. 176
  3397. Interface for Start Manager
  3398.  
  3399. TYPE    DefStartType = (slotDev,scsiDev);
  3400.  
  3401.     DefStartPtr = ^DefStartRec
  3402.     DefStartRec = RECORD
  3403.             CASE DefStartType OF
  3404.               slotDev:
  3405.               sdExtDevID: SignedByte;   {external device ID}
  3406.               sdPartition: SignedByte;  {reserved}
  3407.               sdSlotNum: SignedByte;    {slot number}
  3408.               sdSRsrcID: SignedByte;    {SResourceID}
  3409.               scsiDev:
  3410.               sdReserved1: SignedByte;  {reserved}
  3411.               sdReserved2: SignedByte;  {reserved}
  3412.               sdRefNum: INTEGER         {driver reference number}
  3413.             END;
  3414.  
  3415.     DefVideoPtr = ^DefVideoRec
  3416.     DefVideoRec = RECORD
  3417.             sdSlot: SignedByte;         {slot number}
  3418.             sdSResource: SignedByte;    {sResourceID}
  3419.           END;
  3420.  
  3421.     DefOSPtr = ^DefOSRec
  3422.     DefOSRec = RECORD
  3423.             sdReserved: SignedByte; {reserved--should be 0}
  3424.             sdOSType: SignedByte;   {operating system type}
  3425.           END;
  3426.  
  3427.  
  3428.  
  3429. Assembly-Language Information
  3430.  
  3431. Structure of Default Startup Device Parameter Block (Slot)
  3432.  
  3433. sdExtDevID  External device ID (byte)
  3434. sdPartition Reserved—should be 0 (byte)
  3435. sdSlotNum   Slot number (byte)
  3436. sdSRsrcID   SResource ID (byte)
  3437.  
  3438.  
  3439. Structure of Default Startup Device Parameter Block (SCSI)
  3440.  
  3441. sdReserved1 Reserved—should be 0 (byte)
  3442. sdReserved2 Reserved—should be 0 (byte
  3443. sdRefNum    Driver reference number (word)
  3444.  
  3445.  
  3446. Structure of Default Video Device Parameter Block
  3447.  
  3448. sdSlot      Slot number (byte)
  3449. sdSResource SResource ID (byte)
  3450.  
  3451.  
  3452. Structure of Default OS Parameter Block
  3453.  
  3454. sdReserved  Reserved—should be 0 (byte)
  3455. sdOSType    Operating system type (byte)
  3456.  
  3457. Variables
  3458.  
  3459. CPUFlag Microprocessor in use (word)
  3460.  
  3461. TimeDBRA    Number of times the DBRA instruction can be executed per millisecond (word)
  3462. TimeSCCDB   Number of times the SCC can be accessed per millisecond (word)
  3463. TimeSCSIDB  Number of times the SCSI can be accessed per millisecond (word)
  3464. \,177
  3465. 177
  3466. Interface for Deferred Task Manager
  3467.  
  3468. TYPE
  3469.   DeferredTask = RECORD
  3470.     qLink: QElemPtr;    {next queue entry}
  3471.     qType: INTEGER;     {queue type}
  3472.     dtFlags: INTEGER;   {reserved}
  3473.     dtAddr: ProcPtr;    {pointer to task}
  3474.     dtParm: LONGINT;    {optional parameter}
  3475.     dtReserved: LONGINT {reserved--should be 0}
  3476.   END;
  3477.  
  3478. Assembly-Language Information
  3479.  
  3480. Structure of Deferred Task Manager Queue Entry
  3481.  
  3482. qLink       Pointer to next queue entry
  3483. qType       Queue type (word)
  3484. dtFlags     Reserved (word)
  3485. dtAddr      Address of task
  3486. dtParm      Optional parameter (long)
  3487. dtResrvd    Reserved—should be 0 (long)
  3488. dtQElSize   Size in bytes of queue element
  3489.  
  3490. Variables
  3491.  
  3492. DTQueue Deferred task queue header (10 bytes)
  3493. JDTInstall  Jump vector for DTInstall routine
  3494. \,166
  3495. 166
  3496. Interface for MPW Performance routines
  3497.  
  3498. TYPE
  3499.  
  3500. PLongs = ^ALongs;
  3501. ALongs = ARRAY [1..8000] OF LONGINT;
  3502.  
  3503. PInts = ^AInts;
  3504. HInts = ^PInts;
  3505.  
  3506. AInts = ARRAY [1..8000] OF INTEGER;
  3507.  
  3508. { PerfGlobals are declared as a record, so main program can allocate
  3509. as globals, desk accessory can add to globals allocated via pointer,
  3510. print driver can allocate via low memory, etc. }
  3511.  
  3512.  
  3513. TP2PerfGlobals = ^TPerfGlobals;
  3514. TPerfGlobals = RECORD
  3515.     startROM: LONGINT;          {ROM Base}
  3516.     romHits: LONGINT;           {used if MeasureROM is false}
  3517.     misses: LONGINT;            {count of PC values outside measured memory}
  3518.     segArray: PLongs;           {array of segment handles}
  3519.     sizeArray: PLongs;          {array of segment sizes}
  3520.     idArray: HInts;             {array of segment rsrc IDs}
  3521.     baseArray: PLongs;          {array of offsets to counters for each segment}
  3522.     samples: PLongs;            {samples buffer}
  3523.     buffSize: LONGINT;          {size of samples buffer in bytes}
  3524.     timeInterval: INTEGER;      {number of clock intervals between interrupts}
  3525.     bucketSize: INTEGER;        {size of buckets power of 2}
  3526.     log2buckSize: INTEGER;      {used in CvtPC}
  3527.     pcOffset: INTEGER;          {offset to the user PC at interrupt time.}
  3528.     numMeasure: INTEGER;        {# Code segments (w/o jump table)- ROM etc.}
  3529.     firstCode: INTEGER;         {index of first Code segment}
  3530.     takingSamples: BOOLEAN;     {true if sampling is enabled}
  3531.     measureROM: BOOLEAN;
  3532.     measureCode: BOOLEAN;
  3533.     ramSeg: INTEGER;            {index of "segment" record to cover RAM > 0 if RAM (misses) are to be bucketed.}
  3534.     ramBase: LONGINT;           {beginning of RAM being measured.}
  3535.     measureRAMbucketSize: INTEGER;
  3536.     measureRAMlog2buckSize: INTEGER;
  3537.     romVersion: INTEGER;
  3538.     vRefNum: INTEGER;           {Volume where the report file is to be created}
  3539.     volumeSelected: BOOLEAN;    {True if user selects the report file name}
  3540.     rptFileName: Str255;        {Report file name}
  3541.     rptFileCreator: Str255;     {Report File Creator}
  3542.     rptFileType: Str255;        {Report File type}
  3543.     getResType: ResType;        {Resource type}
  3544.     END;
  3545.  
  3546. \ ,178
  3547. 178
  3548. Interface information for writing HC 2.0 XCMDS
  3549.  
  3550. External windows are an extension of external commands (XCMDs and XFCNs). Two new callbacks, NewXWindow and GetNewXWindow, cause HyperCard to create a new window and save with it a reference to the XCMD that made the call. Then, whenever HyperCard receives an event from the Toolbox Event Manager which belongs to the window, it calls the XCMD that created the window with arguments that allow it to handle the event. Otherwise, HyperCard handles the event itself.
  3551. Whenever an XCMD is called by HyperCard, it receives a pointer to an XCMDBlock, just as it did in earlier versions of HyperCard.
  3552.   XCmdPtr   = ^XCmdBlock;
  3553.   XCmdBlock = RECORD
  3554.                 paramCount:     INTEGER;
  3555.                 params:         ARRAY[1..16] OF Handle;
  3556.                 returnValue:    Handle; 
  3557.                 passFlag:       BOOLEAN;
  3558.                 entryPoint:     ProcPtr; { to call back to HyperCard }
  3559.                 request:        INTEGER;
  3560.                 result:         INTEGER;
  3561.                 inArgs:         ARRAY[1..8] OF LongInt;
  3562.                 outArgs:        ARRAY[1..4] OF LongInt;
  3563.               END;
  3564.  
  3565. When HyperCard calls an XCMD to handle an event for an external window, some of the fields of the XCMDBlock have a new meaning. The paramCount field is set to -1, indicating that the XCMD has been called to handle an event. The first parameter, params[1],  is a pointer to an XWEventInfo block, defined as follows.
  3566.   XWEventInfoPtr = ^XWEventInfo;
  3567.   XWEventInfo    = RECORD
  3568.                      event:       EventRecord;
  3569.                      eventWindow: WindowPtr;
  3570.                      eventParams: ARRAY[1..9] OF LongInt;
  3571.                      eventResult: Handle;
  3572.                    END;
  3573. \ InitResources
  3574. 1
  3575. Function InitResources : INTEGER;
  3576.  
  3577.     InitResources is called by the system whcn it starts up, and should
  3578. not be called by the application. It initializes the Resource Manager,
  3579. opens the system resource file, reads the resource map from the file
  3580. into memory, and returns a reference number for the file.
  3581.  
  3582. (note)
  3583.     The application doesn't need the reference number for the
  3584.     system resource file, because every Resource Manager
  3585.     routine that has a reference number as a parameter
  3586.     interprets Ø to mean the system resource file.
  3587.  
  3588.  
  3589. \ RsrcZoneInit
  3590. 1
  3591. Procedure RsrcZoneInit;
  3592.  
  3593.     RsrcZoneInit is called automatically when your application starts
  3594. up, to initialize the resource map read from the system resource file;
  3595. normally you'll have no need to call it directly. It "cleans up" after
  3596. any resource access that may have been done by a previous application.
  3597. First it closes all open resource files except the system resource
  3598. file. Then, for every system resource that was read into the
  3599. application heap (that is, whose resSysHeap attribute is Ø), it
  3600. replaces the handle to that resource in the resource map with NIL.
  3601. This lets the Resource Manager know that the resource will have to be
  3602. read in again (since the previous application heap is no longer
  3603. around).
  3604.  
  3605.  
  3606. \ CreateResFile
  3607. 1
  3608. Procedure CreateResFile (fileName: Str255);
  3609.  
  3610.     CreateResFile creates a resource file containing no resource data or
  3611. copy of the file's directory entry. If there's no file at all with the
  3612. given name, it also creates an empty data fork for the file. If
  3613. there's already a resource file with the given name (that is, a
  3614. resource form that isn't empty), CreateResFile will do nothing and the
  3615. ResError function will return an appropriate Operating System result
  3616. code.
  3617.  
  3618. (note)
  3619.     Before you can work with the resource file, you need to
  3620.     open it with OpenResFile.
  3621.  
  3622.  
  3623. \ OpenResFile
  3624. 1
  3625. Function OpenResFile (fileName: Str255) : INTEGER;
  3626.  
  3627.     OpenResFile opens the resource file having the given name and makes
  3628. it the current resource file. It reads the resource map from the file
  3629. into memory and returns a reference number for the file. It also reads
  3630. in every resource whose resPreload attribute is set. If the resource
  3631. file is already open, it doesn't make it the current resource file; it
  3632. simply returns the reference number.
  3633.  
  3634. (note)
  3635.     You don't have to call OpenResFile to open the system
  3636.     Resource file or the application's resource file, because
  3637.     they're opened when the system and the application start
  3638.     up, respectively. To get the reference number of the
  3639.     application's resource file, you can call CurResFile
  3640.     after the application starts up (before you open any
  3641.     other resource file).
  3642.  
  3643.     If the file can't be opened, OpenResÏile will return -1 and the
  3644. ResError function will return an appropriate Operating System result
  3645. code. For example, an error occurs if there's no resource file with
  3646. the given name.
  3647.  
  3648. \ CloseResFile
  3649. 1
  3650. Procedure CloseResFile (refNum: INTEGER);
  3651.  
  3652.     Given the reference number of a resource file, CloseResFile does the
  3653. following:
  3654.  
  3655.     - updates the resource file by calling the UpdateResFile procedure
  3656.  
  3657.     - for each resource in the resource file, releases the memory it
  3658.       occupies by calling the ReleaseResource procedure
  3659.  
  3660.     - releases the memory occupied by the resource map
  3661.  
  3662.     - closes the resource file
  3663.  
  3664.     If there's no resource file open with the given reference number,
  3665. CloseResFile will do nothing and the ResError function will return the
  3666. result code resFNotFound. A refNum of Ø represents the system resource
  3667. file, but if you ask to close this file, CloseResFile first closes all
  3668. other open resource files.
  3669.  
  3670.     A CloseResFile of every open resource file except the system
  3671. resource file is done automatically when the application terminates. So
  3672. you only need to call CloseResFile if you want to close the system
  3673. resource file, or if you want to close any resource file before the
  3674. application terminates.
  3675.  
  3676.  
  3677. \ ResError
  3678. 1
  3679. Function ResError : INTEGER;
  3680.  
  3681.     Called after one of the various Resource Manager routines that may
  3682. result in an error condition, ResError returns a result code
  3683. identifying the error, if any. If no error occurred, it returns the
  3684. result code
  3685.  
  3686.     CONST  noErr = Ø; {no error}
  3687.  
  3688.     If an error occurred at the Operating System level, it returns an
  3689. Operating System result code, such as the File Manager "disk I/O" error
  3690. or the Memory Manager "out of memory" error. (See the File Manager and
  3691. Memory Manager manuals for a list of the result codes.)  If an error
  3692. happened at the Resource Manager level, ResError returns one of the
  3693. following result codes:
  3694.  
  3695.     CONST   resNotFound  =  -192;   {resource not found}
  3696.         resFNotFound =  -193;   {resouce file not found}
  3697.         addResFailed =  -194;   {AddResource failed}
  3698.         rmvResFailed =  -196;   {RmveResource failed}
  3699.  
  3700.     Each routine description tells which errors may occur for that
  3701. routine. You can also check for an error after system startup, which
  3702. calls InitResources, and application startup, which opens the
  3703. application's resource file.
  3704.  
  3705.  
  3706. \ CurResFile
  3707. 1
  3708. Function CurResFile  : INTEGER;
  3709.  
  3710.     CurResFile returns the reference number of the current resource file
  3711. You can call it when the application starts up to get the reference
  3712. number of its resource file.
  3713.  
  3714. (note)
  3715.     If the system resource file is the current resource file,
  3716.     CurResFile returns the actual reference number of the
  3717.     system reference file (found in the global variable
  3718.     SysMap). You needn't worry about this number being used
  3719.     (instead of Ø in the routines that require a reference
  3720.     number; these routines recognize both Ø and the actual
  3721.     reference number as referring to the system resource
  3722.     file.
  3723.  
  3724. \ HomeResFile
  3725. 1
  3726. Function HomeResFile  (theResource: Handle)  :  INTEGER;
  3727.  
  3728.     Given a handle to a resource, HomeResFile returns the reference
  3729. number of the resource file containing that resource. If the given
  3730. handle isn't a handle to a resource, HomeResFile will return -1 and the
  3731. ResError function will return the result code resNotFound.
  3732.  
  3733.  
  3734. \ UseResFile
  3735. 1
  3736. Procedure UseResFile  (refNum:  INTEGER);
  3737.  
  3738.     Given the reference number of a resource file, UseResFile sets the
  3739. current resource file to that file. If there's no resource file open
  3740. with the given reference number, UseResFile will do nothing and the
  3741. ResError function will return the result code resFNotFound. A refNum
  3742. of Ø represents the system resource file.
  3743.  
  3744.     Open resource files are arranged as a linked list; the most recently
  3745. opened file is at the end of the list and is the first one to be
  3746. searched. UseResFile lets you start the search with a file opened
  3747. earlier; the file(s) following it on the list ate then left out of the
  3748. search process. This is best understood with an example. Assume there
  3749. are four open resource files (RØ through R3); the search order is R3,
  3750. R2, R1, RØ. If you call UseResFile(R2), the search order becomes R2,
  3751. R1, RØ; R3 is no longer searched. If you then open a fifth resource
  3752. file (R4), it's added to the end of the list and the search order
  3753. becomes R4, R3, R2, R1, RØ.
  3754.  
  3755.     This procedure is useful if you no longer want to override a system
  3756. resource with one by the same name in your application's resource file.
  3757. You can call UseResFile(Ø) to leave the application resource file out
  3758. of the search, causing only the system resource file to be searched.
  3759.  
  3760. (warning)
  3761.     Early versions of some desk accessories may, upon
  3762.     closing, always set the current resource file to the one
  3763.     opened just prior to the accessory, ignoring any
  3764.     additional resource files that may have been opened while
  3765.     the accessory was in use. To be safe, whenever desk
  3766.     accessories may have been in use, call UseResFile to
  3767.     ensure access to resource files opened after accessories.
  3768.  
  3769.  
  3770. \ CountTypes
  3771. 1
  3772. Function CountTypes : INTEGER;
  3773.  
  3774.     CountTypes returns the number of resource types in all open resource
  3775. files.
  3776.  
  3777.  
  3778. \ GetIndType
  3779. 1
  3780. Procedure GetIndType (VAR theType: ResType; index: INTEGER);
  3781.  
  3782.     Given an index ranging from 1 to CountTypes (above, GetIndType
  3783. returns a resource type in theType. Called repeatedly over the entire
  3784. range  for the index, it returns all the resource types in all open
  3785. resource files. If the given index isn't in the range from 1 to
  3786. CountTypes,  GetIndType returns four NUL characters (ASCII code Ø).
  3787.  
  3788.  
  3789. \ SetResLoad
  3790. 1
  3791. Procedure SetResLoad (load: BOOLEAN);
  3792.  
  3793.     Normally, the routines that return handles to resources read the
  3794. resource data into memory if it's not already in memory.
  3795. SetResLoad(FALSE) affects all those routines so that they will not read
  3796. the resource data into memory and will return an empty handle.
  3797. Resources whose resPreload attrribute is set will still be read in,
  3798. however, when a resource file is opened. SetResLoad(TRUE) restores the
  3799. normal state.
  3800.  
  3801. (warning)
  3802.     If you call SetResLoad(FALSE), be sure to restore the
  3803.     normal state as soon as possible, because other parts of
  3804.     the Toolbox that call the Resource Manager rely on it.
  3805.  
  3806.  
  3807. \ CountResources
  3808. 1
  3809. Function CountResources (theType: ResType) : INTEGER;
  3810.  
  3811.     CountResources returns the total number of resources of the given
  3812. type in all open resource files.
  3813.  
  3814.  
  3815. \ GetIndResource
  3816. 1
  3817. Function GetIndResource (theType: ResType; index: INTEGER) : Handle;
  3818.  
  3819.     Given an index ranging from 1 to CountResources(theType),
  3820. GetIndResource returns a handle to a resource of the given type (see
  3821. CountResources, above). Called repeatedly over the entire range for
  3822. the index, it returns handles to all resources of the given type in all
  3823. open resource files. GetIndResource reads the resource data into
  3824. memory if it's not already in memory, unless you've called
  3825. SetResLoad(FALSE).
  3826.  
  3827. (warning)
  3828.     The handle returned will be an empty handle if you've
  3829.     called SetResLoad(FALSE) (and the data isn't already in
  3830.     memory). The handle will become empty if the resource
  3831.     data for a purgeable resource is read in but later
  3832.     purged. (You can test for an empty handle with, for
  3833.     example, myHndl^= NIL.)  To read in the data and make
  3834.     the handle no longer be empty, you can call LoadResource.
  3835.  
  3836.     GetIndResource returns handles for all resources in the most
  3837. recently opened resource file first, and then for those in the resource
  3838. files opened before it, in the reverse of the order that they were
  3839. opened. If you want to find out how many resources of a given type are
  3840. in a particular resource file, you can do so as follows:  Call
  3841. GetIndResource repeatedly with the index ranging from 1 to the number
  3842. of resources of that type. Pass each handle returned by GetIndResource
  3843. to HomeResFile and count all occurrences where the reference number
  3844. returned is that of the desired file. Be sure to start the index from
  3845. 1, and to call SetResLoad(FALSE) so the resources won't be read in.
  3846.  
  3847. (note)
  3848.     The UseResFile procedure affects which file the Resource
  3849.     Manager searches first when looking for a particular
  3850.     resource but not when getting indexed resources  with
  3851.     GetIndResource.
  3852.  
  3853.     If the given index isn't in the range from 1 to
  3854. CountResources(theType), GetIndResource returns NIL and the ResError
  3855. Function will return the result code resNotFound. GetIndResource also
  3856. returns NIL if the resource is to be read into memory but won't fit; in
  3857. this case, ResError will return an appropriate Operating System result
  3858. code.
  3859.  
  3860.  
  3861. \ GetResource
  3862. 1
  3863. Function GetResource (theType: ResType; the ID: INTEGER) : Handle;
  3864.  
  3865.     GetResource returns a handle to the resource having the given type
  3866. and ID number, reading the resource data into memory if it's not already
  3867. in memory and if you haven't called SetResLoad(FALSE) (see the warning
  3868. aboove for GetIndResource). GetResource looks in the current resource
  3869. file and all resource files opened before it, in the reverse of the
  3870. order that they were opened; the system resource file is searched last.
  3871. If it doesn't find the resource, GetResource returns NIL and the
  3872. ResError function will return the result code resNotFound. GetResource
  3873. also returns NIL if the resource is to be read into memory but won't
  3874. fit; in this case, ResError will return an appropriate Operating System
  3875. result code.
  3876.  
  3877.  
  3878. \ GetNamedResource
  3879. 1
  3880. Function GetNamedResource (theType: ResType; name: Str255) : Handle;
  3881.  
  3882.     GetNamedResource is the same as GetResource (above) except that you
  3883. pass a resource name instead of an ID number.
  3884.  
  3885.  
  3886. \ LoadResource
  3887. 1
  3888. Procedure LoadResource (theResource: Handle);
  3889.  
  3890.     Given a handle to a resource (returned by GetIndResource,
  3891. GetResource, or GetNamedResource), LoadResource reads that resource into
  3892. memory. It does nothing if the resource is already in memory or if the
  3893. given handle isn't a handle to a resource; in the latter case, the
  3894. ResError function will return the result code resNotFound. Call this
  3895. Procedure if you want to access the data for a resource through its
  3896. handle and either you've called SetResLoad(FALSE) or if the resource is
  3897. purgeable.
  3898.  
  3899.     If you've changed the resource data for a purgeable resource and the
  3900. resource is purged before being written to the resource file, the
  3901. changes will be lost; LoadResource will reread the original resource
  3902. from the resource file. See the descriptions of ChangedResource and
  3903. SetResPurge for information about how to ensure that changes made to
  3904. purgeable resources will be written to the research file.
  3905.  
  3906.  
  3907. \ ReleaseResource
  3908. 1
  3909. Procedure ReleaseResource (theResource: Handle);
  3910.  
  3911.     Given a handle to a resource, ReleaseResource releases the memory
  3912. occupied by the resource data, if any, and replaces the handle to that
  3913. resource in the resource map with NIL. (See Figure 7.)  The given
  3914. handle will no longer be recognized as a handle to a resource; if the
  3915. Resource Manager is subsequently called to get the released resource, a
  3916. new handle will be allocated. Use this procedure only after you're
  3917. completely through with a resource.
  3918.  
  3919.  
  3920. \ DetachResource
  3921. 1
  3922. Procedure DetachResource (theResource: Handle);
  3923.  
  3924.     Given a handle to a resource, DetachResource replaces the handle to
  3925. that resource in the resource map with NIL. (See Figure 7 above.)  The
  3926. given handle will no longer be recognized as a handle to a resource; if
  3927. the Resource Manager is subsequently called to get the detached
  3928. resource, a new handle will be allocated.
  3929.  
  3930.     DetachResource is useful if you want the resource data to be
  3931. accessed only by yourself through the given handle and not by the
  3932. Resource Manager. DetachResource is also useful in the unusual case
  3933. that you don't want a resource to be released when a resource file is
  3934. closed. To copy a resource, you can call DetachResource followed by
  3935. AddResource (with a new resource ID).
  3936.  
  3937.     If the given handle isn't a handle to a resource, DetachResopurce
  3938. will  do nothing and the ResError function will return the result code
  3939. resNotFound.
  3940.  
  3941.  
  3942. \ UniqueID
  3943. 1
  3944. Function UniqueID (theType: ResType) : INTEGER;
  3945.  
  3946.     UniqueID returns an ID number greater than Ø that isn't currently
  3947. assigned to any resource of the given type in any open resource file.
  3948. Using this number when you add a new resource to a resource file
  3949. ensures that you won't duplicate a resource ID and override an existing
  3950. resource.
  3951.  
  3952. (warning)
  3953.     It's possible that UniqueID will return an ID in the
  3954.     range reserved for system resources (Ø to 127). You
  3955.     should check that the ID returned is greater than 127; if
  3956.     it isn't, call UniqueID again.
  3957.  
  3958.  
  3959. \ GetResInfo
  3960. 1
  3961. Procedure GetResInfo (theResource: Handle; VAR theID: INTEGER; VAR
  3962.         theType: ResType; VAR name: Str255);
  3963.  
  3964.     Given a handle to a resource, GetResInfo returns the ID number,
  3965. type, and name of the resource. If the given handle isn't a handle to a
  3966. resource, GetResInfo will do nothing and the ResError function will
  3967. return the result code resNotFound.
  3968.  
  3969.  
  3970. \ GetResAttrs
  3971. 1
  3972. Function GetResAttrs (theResource: Handle) : INTEGER;
  3973.  
  3974.     Given a handle to a resource, GetResAttrs returns the resource
  3975. attributes for the resource. (Resource attributes are described above
  3976. under "Resource References".)  If the given handle isn't a handle to a
  3977. resource, GetResAttrs will do nothing and the ResError function will
  3978. return the result code resNotFound.
  3979.  
  3980.  
  3981. \ SizeResource
  3982. 1
  3983. Function SizeResource (the Resource: Handle) : LONGINT;
  3984.  
  3985.     Given a handle to a resource, Size Resource returns the size in
  3986. bytes of the resource in the resource file. If the given handle isn't a
  3987. handle  to a resource, SizeResource will return -1 and the ResError
  3988. Function will return the result code resNotFound. It's a good idea to
  3989. call SizeResource and ensure that sufficient space is available before
  3990. reading a resource into memory.
  3991.  
  3992.  
  3993. \ SetResInfo
  3994. 1
  3995. Procedure SetResInfo (theResource: Handle; theID: INTEGER;
  3996.                         name: Str255);
  3997.  
  3998.     Given a handle to a resource, SetResInfo changes the ID number and
  3999. name of the resource to the given ID number and name.
  4000.     _______________________________________________________________
  4001.     Assembly-language note:  If you pass NIL for the name parameter,
  4002.     the name will not be changed.
  4003.     _______________________________________________________________
  4004.  
  4005. (warning)
  4006.     It's a dangerous practice to change the ID number and
  4007.     name of a system resource, because other applications may
  4008.     already access the resource and may no longer work
  4009.     properly.
  4010.  
  4011.     The change will be written to the resource file when the file is
  4012. updated if you follow SetResInfo with a call to ChangedResource.
  4013.  
  4014. (warning)
  4015.     Even if you don't call Changed Resource for this resource,
  4016.     the change may be written to the resource file when the
  4017.     file is updated. If you've ever called ChangedResource
  4018.     for any resource in the file, or if you've added or
  4019.     removed a resource, the Resource Manager will write out
  4020.     the entire resource map when it updates the file, so all
  4021.     changes made to resource information in the map will
  4022.     become permanent. If you want any of the changes to be
  4023.     temprary, you'll have to restore the original
  4024.     information before the file is updated.
  4025.  
  4026. SetResInfo does nothing in the following cases:
  4027.  
  4028.     - The resProtected attribute for the resource is set.
  4029.  
  4030.     - The given handle isn't a handle to a resource. The ResError
  4031.       function will return the result code resNotFound.
  4032.  
  4033.     - The resource map becomes too large to fit in memory (which can
  4034.       happen if a name is passed) or sufficient space for the modified
  4035.       resource file can't be reserved on the disk. ResError will return
  4036.       an appropriate Operating System result code.
  4037.  
  4038.  
  4039. \ SetResAttrs
  4040. 1
  4041. Procedure SetResAttrs (theResource: Handle; attrs: INTEGER);
  4042.  
  4043.     Given a handle to a resource, SetResAttrs sets the resource
  4044. attributes for the resource to attrs. (Resource attributes are
  4045. described above under "Resource Refererence".)  The resProtected
  4046. attribute takes effect immediately; the others take effect the next time
  4047. the resource is read in.
  4048.  
  4049. (warning)
  4050.     Do not use SetResAttrs to set the resChanged attribute;
  4051.     you must call Changed Resource instead. Be sure that the
  4052.     attrs parameter passed to SetResAttrs doesn't change the
  4053.     current setting of this attribute.
  4054.  
  4055.     The attributes set with SetResAttrs will be written to the resource
  4056. file when the file is updated if you follow SetResAttrs with a call to
  4057. ChangedResource. However, even if you don't call ChangedResource for
  4058. this resource, the change may be written to the resource file when the
  4059. file is updated. See the last warning for SetResInfo (above).
  4060.  
  4061.     If the given handle isn't a handle to a resource, SetResAttrs will
  4062. do nothing and the ResError function will return the result code
  4063. resNotFound.
  4064.  
  4065.  
  4066. \ ChangedResource
  4067. 1
  4068. Procedure ChangedResource (theResource: Handle);
  4069.  
  4070.     Call ChangedResource after changing either the information about a
  4071. resource in the resource map (as described above under SetResInfo and
  4072. SetResAttrs) or the resource data for a resource, if you want the
  4073. change to be permanent. Given a handle to a resource, ChangedResource
  4074. sets the resChanged attribute for the resource. This attribute tells
  4075. the Resource Manager to do both of the following:
  4076.  
  4077.     - write the resource data for the resource to the resource file when
  4078.       the file is updated or when WriteResource is called
  4079.  
  4080.     - write the entire resource map to the resource file when the file
  4081.       is updated.
  4082.  
  4083. (warning)
  4084.     If you change information in the resource map with
  4085.     SetResÈnfo or SetResAttrs and then call ChangedResource,
  4086.     remember that not only the resource map but also the
  4087.     resource data will be written out when the resource file
  4088.     is updated.
  4089.  
  4090.     To change the resource data for a purgeable resource and make the
  4091. change permanent, you have to take special precautions to ensure that
  4092. the resource won't be purged while you're changing it. You can make
  4093. the resource temporarily unpurgeable and then write it out with
  4094. WriteResource before making it purgeable again. You have to use the
  4095. Memory Manager procedures  HNoPurge and HPurge to make the resource
  4096. unpurgeable and purgeable; SetResAttrs can't be used because it won't
  4097. take effect immediately. For example:
  4098.  
  4099.     myHndl := GetResource(type,ID;  {or LoadResource(myHndl) if  }
  4100.                     { you've gotten it previously}
  4101.     HNoPurge(myHndl);       {make it unpurgeable}
  4102.       . .  .          {make the changes here}
  4103.     ChangedResource(myHndl);    {mark it changed}
  4104.         WriteResource(myHndl);      {write it out}
  4105.     HPurge(myHndl)          {make it purgeable again}
  4106.  
  4107.     Or, instead of calling WriteResource to write the data out
  4108. immediately, you can call SetResPurge(TRUE) before making any changes to
  4109. purgeable resource data.
  4110.  
  4111. ChangedResource does nothing in the following cases:
  4112.  
  4113.     - The given handle isn't a handle to a resource. The ResError
  4114.       function will return the result code resNotFound.
  4115.  
  4116.     - Sufficient space for the modified resource file can't be reserved
  4117.       on the disk. ResError will return an appropriate Operating System
  4118.       result code.
  4119.  
  4120. (warning)
  4121.     Be aware that ChangedResource (and not WriteResource)
  4122.     checks to see if there's sufficient disk space to write
  4123.     out the modified file; it there isn't enough space, the
  4124.     resChanged attribute won't be set. This means that when
  4125.     Write Resource is called,it won't know that the resource
  4126.     file has been changed; it won't write out the modified
  4127.     file and no error will be returned. For this reason,
  4128.     always check to see that ChangedResource returns noErr.
  4129.  
  4130.  
  4131. \ AddResource
  4132. 1
  4133. Procedure AddResource (theData: Handle; theType: ResType; theID:
  4134.         INTEGER; name: Str255);
  4135.  
  4136.     Given a handle to data in memory (not a handle to an existing
  4137. resource), AddResource adds to the current resource file a resource
  4138. reference that points to the data. It sets the resChanged attribute
  4139. for the resource, so the data will be written to the resource file when
  4140. the file is updated or when WriteResource is called. If the given
  4141. handle is empty, zero-length resource data will be written.
  4142. AddResource does nothing in the following cases:
  4143.  
  4144.     - The given handle is NIL or is already a handle to an existing
  4145.       resource. The ResError function will return the result code
  4146.       addResFailed.
  4147.  
  4148.     - The resource map becomes too large to fit in memory or sufficient
  4149.       space for the modified resource file can't be reserved on the
  4150.       disk. ResError will return an appropriate Operating System result
  4151.       code.
  4152.  
  4153. (warning)
  4154.     AddResource doesn't verify whether the resource ID you've
  4155.     passed is already assigned to another resource of the
  4156.     same type; be sure to call UniqueID before adding a
  4157.     resource.
  4158.  
  4159.  
  4160. \ RmveResource
  4161. 1
  4162. Procedure RmveResource (theResource: Handle);
  4163.  
  4164.     Given a handle to a resource in the current resource file,
  4165. RmveResource removes the resource reference to the resource. The
  4166. resource data will  be removed from the resource file when the file is
  4167. updated.
  4168.  
  4169. (note)
  4170.     RmveResource doesn't release the memory occupied by the
  4171.     resource data; to do that, call the Memory Manager
  4172.     procedure DisposHandle after calling RmveResource.
  4173.  
  4174.     If the resProtected attribute for the resource is set or if the
  4175. given handle isn't a handle to a resource in the current resource file,
  4176. Rmve Resource will do nothing and the ResError function will return the
  4177. result code rmvResFailed.
  4178.  
  4179.  
  4180. \ UpdateResFile
  4181. 1
  4182. Procedure UpdateResFile (refNum: INTEGER);
  4183.  
  4184.     Given the reference number of a resource file, UpdateResFile does
  4185. the following:
  4186.  
  4187.     - Changes, adds, or removes resource data in the file as appropriate
  4188.       to match the map. Remember that changed resource data is written
  4189.       out only if you called ChangedResource (and the call was
  4190.       successful); if you did, the resource data will be written out
  4191.       with WriteResource.
  4192.  
  4193.     - Compacts the resource file, closing up any empty space created
  4194.       when a resource was removed or made larger. (If the size of a
  4195.       changed resource is greater than its original size in the resource
  4196.       file, it's written at the end of the file rather than at its
  4197.       original location; the space occupied by the original is then
  4198.       compacted.)  UpdateResFile doesn't close up any empty space
  4199.       created when a resource is made smaller.
  4200.  
  4201.     - Writes out the resource map of the resource file, if you ever
  4202.       called ChangedResource for any resource in the file or if you
  4203.       added or removed a resource. All changes to resource information
  4204.       in the map will become permanent as a result of this, so if you
  4205.       want any such changes to be temporary, you must restore the
  4206.       original information before calling UpdateResFile.
  4207.  
  4208.     If there's no open resource file with the given reference number,
  4209. UpdateResFile will do nothing and the ResError function will return the
  4210. result code resFNotFound. A refNum of Ø represent the system resource
  4211. file.
  4212.  
  4213.     The CloseResFile procedure calls UpdateResFile before it closes the
  4214. resource file, so you only need to call UpdateResFile yourself if you
  4215. want to update the file without closing it.
  4216.  
  4217.  
  4218. \ WriteResource
  4219. 1
  4220. Procedure WriteResource (theResource: Handle);
  4221.  
  4222.     Given a handle to a resource, WriteResource checks the resChanged
  4223. attribute for that resource and, if it's set (which it will be if you
  4224. called ChangedResource or AddResource successfully), writes its
  4225. resource data to the resource file and clears its resChanged attribute.
  4226.  
  4227. (warning)
  4228.     Be aware that ChangedResource (and not WriteResource)
  4229.     determines if sufficient disk space is available to write
  4230.     out the modified file; if there isn't it will clear the
  4231.     resChanged attribute and WriteResource will be unaware of
  4232.     the modifications. For this reason, always verify that
  4233.     ChangedResource returns noErr.
  4234.  
  4235.     If the resource is purgeable and has been purged, zero-length
  4236. resource data will be written. WriteResource does nothing if the
  4237. resProtected attribute for the resource is set or if the given handle
  4238. isn't a handle to a resource; in the latter case, the ResError function
  4239. will return the result code resNotFound.
  4240.  
  4241.     Since the resource file is updated when the application terminates
  4242. or when you call UpdateResFile (or CloseResFile, which calls
  4243. UpdateResFile), you only need to call WriteResource if you want to
  4244. write out just one or a few resources immediately.
  4245.  
  4246. (warning)
  4247.     The maximum size for resources to be written to a
  4248.     resource file is 32K bytes.
  4249.  
  4250.  
  4251. \ SetResPurge
  4252. 1
  4253. Procedure SetResPurge (install: BOOLEAN);
  4254.  
  4255.     SetResPurge(TRUE) sets a  "hook" in the Memory Manager such that
  4256. before purging data specified by a handle,the Memory Manager will first
  4257. pass the handle to the Resource Manager. The Resource Manager will
  4258. determine whether the handle is that of a resource in the application
  4259. heap and, if so, will call WriteResource to write the resource data for
  4260. that resource to the resource file if its resChanged attribute is set
  4261. (see ChangedResource and WriteResource above). SetResPurge(FALSE)
  4262. restores the normal state, clearing the hook so that the Memory Manager
  4263. will once again purge without checking with the Resource Manager.
  4264.  
  4265.     SetResPurge(TRUE) is useful in applications that modify purgeable
  4266. resources. You still have to make the resources temporarily
  4267. unpurgeable while making the changes, as shown in the description of
  4268. ChangedResource, but you can set the purge hook instead of writing the
  4269. data out immediately with WriteResource. Notice that you won't know
  4270. exactly when the resources are being written out; most applications
  4271. will want more control than this. If you wish, you can set your own
  4272. such hook; for details, refer to the section "Memory Manager Data
  4273. Structures" in the Memory Manager manual.
  4274.  
  4275.  
  4276. \ GetResFileAttrs
  4277. 1
  4278. Function GetResFileAttrs (refNum: INTEGER) : INTEGER;
  4279.  
  4280.     Given the reference number of a resource file, GetResFileAttrs
  4281. returns the resource file attributes for the file. If there's no
  4282. resource file with the given reference number, GetResFileAttrs will do
  4283. nothing and the ResError function will return the result code
  4284. resFNotFound. A refNum of Ø represents the system resource file.
  4285.  
  4286.  
  4287. \ SetResFileAttrs
  4288. 1
  4289. Procedure SetResFileAttrs (refNum: INTEGER; attrs: INTEGER);
  4290.  
  4291.     Given the reference number of a resource file, SetResFileAttrs sets
  4292. the  resource file attributes of the file to attrs. If there's no
  4293. resource file with the given reference number, SetResFileAttrs will do
  4294. nothing and the ResError function will return the result code
  4295. resFNotFound. A refNum of  Ø represents the system resource file, but
  4296. you shouldn't change its resource file attributes.
  4297.  
  4298.  
  4299. \ AddReference
  4300. 1
  4301. Procedure AddReference (theResource: Handle; theID: INTEGER; name:
  4302.       Str255);
  4303.  
  4304.     Given a handle to a system resource, AddReference adds to the
  4305. current resource file a system reference to the resource, giving it the
  4306. ID number and name specified by the parameters. It sets the resChanged
  4307. attribute for the resource, so the reference will be written to the
  4308. resource file when the file is updated. AddReference does nothing in
  4309. the following cases:
  4310.  
  4311.     - The current resource file is the system resource file or already
  4312.       contains a system reference to the specified resource, or the
  4313.       given handle isn't a handle to a system resource. The ResError
  4314.       function will return the result code.
  4315.  
  4316.         CONST addReFailed = -195;  (AddReference failed)
  4317.  
  4318.     - The resource map becomes too large to fit in the memory or
  4319.       sufficient space for the modified resource file can't be
  4320.       reserved on the disk. ResError will return an appropriate
  4321.       Øperating System result code.
  4322.  
  4323.  
  4324. \ RmveReference
  4325. 1
  4326. Procedure RmveReference (theResource: Handle);
  4327.  
  4328.     Given a handle to a system resource, RmveReference removes the
  4329. system reference to the resource from the current resource file. (The
  4330. reference will be removed from the resource file when the file is
  4331. updated.)  RmveReference will do nothing and the ResError function will
  4332. return the result code.
  4333.  
  4334.         CONST rmvRefFailed = -197;  (RmveReference failed)
  4335.  
  4336. if any of the following are true:
  4337.  
  4338.     - The resProtected attribute for the resource is set.
  4339.  
  4340.     - There's no system reference to the resource in the current
  4341.       resource file.
  4342.  
  4343.     - The given handle isn't a handle to a system resource.
  4344.  
  4345. \ Count1Types
  4346. 1
  4347. Function Count1Types : INTEGER;
  4348.  
  4349.     Count1Types is the same as CountTypes except that it returns the
  4350. number of resource types in the current resource file only.
  4351.  
  4352. \ Get1IndType
  4353. 1
  4354. Procedure Get1IndType (VAR theType: ResType; index: INTEGER);
  4355. ___________________________________________________________________
  4356.  
  4357. Assembly-language note:  The macro you invoke to call Get1IndType
  4358. from assembly language is named _Get1IxType.
  4359. ___________________________________________________________________
  4360.     Get1IndType is the same as GetIndType except that it searches the
  4361. current resource file only. Given an index ranging from 1 to
  4362. Count1Types (above), Get1IndType returns a resource type in theType.
  4363.  
  4364.     Called repeatedly over the entire range for the index, it returns
  4365. all the resource types in the current resource file. If the given
  4366. index isn’t in the range from 1 to Count1Types, Get1IndType returns
  4367. four NUL characters (ASCII code 0).
  4368.  
  4369. \ Count1Resources
  4370. 1
  4371. Function Count1Resources (theType: ResType) : INTEGER;
  4372.  
  4373.     Count1Resources is the same as CountResources except that it returns
  4374. the total number of resources of the given type in the current resource
  4375. file only.
  4376.  
  4377. \ Get1IndResource
  4378. 1
  4379. Function Get1IndResource (theType: ResType; index: INTEGER) : Handle;
  4380. ___________________________________________________________________
  4381.  
  4382. Assembly-language note:  The macro you invoke to call
  4383. Get1IndResource from assembly language is named _Get1IxResource.
  4384. ___________________________________________________________________
  4385.     Get1IndResource is the same as GetIndResource except that it
  4386. searches the current resource file only. Given an index ranging from 1
  4387. to Count1Resources(theType), Get1IndResource returns a handle to a
  4388. resource of the given type (see Count1Resources, above). Called
  4389. repeatedly over the entire range for the index, it returns handles to
  4390. all resources of the given type in the current resource file.
  4391.  
  4392. \ Get1Resource
  4393. 1
  4394. Function Get1Resource (theType: ResType; theID: INTEGER) : Handle;
  4395.  
  4396.     Get1Resource is the same as GetResource except that it searches the
  4397. current resource file only.
  4398.  
  4399. \ Get1NamedResource
  4400. 1
  4401. Function Get1NamedResource (theType: ResType; name: Str255) : Handle;
  4402.  
  4403.     Get1NamedResource is the same as GetNamedResource except that it
  4404. searches the current resource file only.
  4405.  
  4406. \ Unique1ID
  4407. 1
  4408. Function Unique1ID (theType: ResType) : INTEGER;
  4409.  
  4410.     Unique1ID is the same as UniqueID except that the ID number it
  4411. returns is unique only with respect to resources in the current resource
  4412. file.
  4413.  
  4414. \ MaxSizeRsrc
  4415. 1
  4416. Function MaxSizeRsrc (theResource: Handle) : LONGINT;
  4417.  
  4418.     MaxSizeRsrc is similar to SizeResource except that it does not cause
  4419. the disk to be read; instead it determines the size (in bytes) of
  4420. the resource from the offsets found in the resource map.
  4421.  
  4422.     Since MaxSizeRsrc does not read from the disk, it returns only the
  4423. maximum size of the resource. In other words, you can count on the
  4424. resource not being larger than the number of bytes reported by
  4425. MaxSizeRsrc; it’s possible, however, that the resource is actually
  4426. smaller than the resource map indicates (because the file has not
  4427. yet been compacted). If called after UpdateResFile, MaxSizeRsrc will
  4428. return the correct size of the resource.
  4429.  
  4430. \ RsrcMapEntry
  4431. 1
  4432. Function RsrcMapEntry (theResource: Handle) : LONGINT;
  4433.  
  4434.     RsrcMapEntry  provides a way to access the resource references in
  4435. the resource map. Given a handle to a resource, RsrcMapEntry returns
  4436. the offset of the resource’s reference from the beginning of the
  4437. resource map. (For more information on resource references and the
  4438. structure of a resource map, see the section “Format of a Resource File”
  4439. in the Resource Manager chapter.)  If it doesn’t find the resource,
  4440. RsrcMapEntry returns NIL and the ResError function will return the
  4441. result code resNotFound. If you pass it a NIL handle, RsrcMapEntry
  4442. will return garbage but ResError will return the result code noErr.
  4443.  
  4444. Warning:  Since routines are provided for opening, accessing,
  4445.           and changing resources, there’s really no reason to access
  4446.           resources directly. To avoid damaging the resource file, you
  4447.           should be extremely careful if you use RsrcMapEntry.
  4448.  
  4449.  
  4450. \ OpenRFPerm
  4451. 1
  4452. Function OpenRFPerm (fileName: Str255; vRefNum: INTEGER; permission: Byte) : INTEGER;
  4453.  
  4454.     OpenRFPerm is similar to OpenResFile except that it allows you to
  4455. specify the read/write permission of the resource file the first time
  4456. it is opened; OpenRFPerm also lets you specify in vRefNum the directory
  4457. or volume on which the file is located (see chapter 19 of this volume
  4458. for more details on directories). Permission can have any of the values
  4459. that you would pass to the File Manager; these values are given
  4460. in “Low-Level File Manager Routines” in chapter 19 of this volume.
  4461.  
  4462.     OpenRFPerm, like OpenResFile, will not open the specified file twice
  4463. it simply returns the reference number already assigned to the file.
  4464. In other words, OpenRFPerm cannot be used to open a second access
  4465. path to a resource file nor can it be used to change the permission
  4466. of an already open file. Since OpenRFPerm gives no indication of
  4467. whether the file was already open, there’s no way to tell whether
  4468. the file’s open permission is what you specified or what was
  4469. specified by an earlier call.
  4470.  
  4471. Note:  The shared read/write permission described in chapter 19
  4472. of this volume has no effect with OpenRFPerm since the Resource
  4473. Manager is unable to deal with a portion of a resource file.
  4474.  
  4475. \ InitGraf
  4476. 2
  4477. Procedure InitGraf (globalPtr: QDPtr);
  4478.  
  4479.     Call InitGraf once and only once at the beginning of your program
  4480. to initialize QuickDraw. It initializes the QuickDraw global variables
  4481. listed below.
  4482.  
  4483.     Variable    Type        Initial Setting
  4484.     -----------------------------------------------
  4485.  
  4486.     thePort     GrafPtr     NIL
  4487.     white       Pattern     all-white pattern
  4488.     black       Pattern     all-black pattern
  4489.     gray        Pattern     50% gray pattern
  4490.     ltGray      Pattern     25% gray pattern
  4491.     dkGray      Pattern     75% gray pattern
  4492.     arrow       Cursor      pointing arrow cursor
  4493.     screenBits  BitMap      Macintosh screen, (Ø,Ø,512,342)
  4494.     randSeed    LongInt     1
  4495.  
  4496.     The globalPtr parameter tells QuickDraw where to store its global
  4497. variables, beginning with thePort. From Pascal programs, this
  4498. parameter should always be set to @the Port; assembly-language
  4499. programmers may choose any location, as long as it can accommodate the
  4500. number of bytes specified by GRAFSIZE in GRAFTYPES.TEXT (see "Using
  4501. QuickDraw from Assembly Language").
  4502.  
  4503. (hand)
  4504.     To initialize the cursor, call InitCursor (described
  4505.     under "Cursor Handling Routines" below).
  4506.  
  4507. \ OpenPort
  4508. 2
  4509. Procedure OpenPort (gp: GrafPtr);
  4510.  
  4511.     OpenPort allocates space for the given grafPort's visRgn and clipRgn
  4512. initializes the fields of the grafPort as indicated below, and makes
  4513. the grafPort the current port (see SetPort). You must call OpenPort
  4514. before using any grafPort; first perform a NEW to create a grafPtr and
  4515. then use  that grafPtr in the OpenPort call.
  4516.  
  4517.     Field       Type        Initial Setting
  4518.  
  4519.     device      INTEGER     Ø (Macintosh screen)
  4520.     portBits    BitMap      screenBits (see InitGraf)
  4521.     portRect    Rect        screenBits.bounds (Ø,Ø,512,342)
  4522.     visRgn      RgnHandle   handle to the rectangular region
  4523.                             (Ø,Ø,512,342)
  4524.     clipRgn     RgnHandle   handle to the rectangular region
  4525.                             (-3ØØØØ,-3ØØØØ,3ØØØØ,3ØØØØ)
  4526.     bkPat       Pattern     white
  4527.     fillPat     Pattern     black
  4528.     pnLoc       Point       (Ø,Ø)
  4529.     pnSize      Point       (1,1)
  4530.     pnMode      INTEGER     patCopy
  4531.     pnPat       Pattern     black
  4532.     pnVis       INTEGER     Ø (visible)
  4533.     txFont      INTEGER     Ø (system font)
  4534.     txFace      Style       normal
  4535.     txMode      INTEGER     srcOr
  4536.     txSize      INTEGER     Ø (Font Manager decides)
  4537.     spExtra     INTEGER     Ø
  4538.     fgColor     LongInt     blackColor
  4539.     bkColor     LongInt     whiteColor
  4540.     colrBit     INTEGER     Ø
  4541.     patStretch  INTEGER     Ø
  4542.     picSave     QDHandle    NIL
  4543.     rgnSave     QDHandle    NIL
  4544.     polySave    QDHandle    NIL
  4545.     grafProcs   QDProcsPtr  Nil
  4546.  
  4547.  
  4548. \ InitPort
  4549. 2
  4550. Procedure InitPort (gp: GrafPtr);
  4551.  
  4552.     Given a pointer to a grafPort that has been opened with OpenPort,
  4553. InitPort reinitializes the fields of the grafPort and makes it the
  4554. current port (if it's not already).
  4555.  
  4556. (hand)
  4557.     InitPort does everything OpenPort does except allocate
  4558.     space for the visRgn and clipRgn.
  4559.  
  4560.  
  4561. \ ClosePort
  4562. 2
  4563. Procedure ClosePort (gp: GrafPtr)
  4564.  
  4565.     ClosePort deallocates the space occupied by the given GrafPort's
  4566. visRgn and clipRgn. When you are completely through with a grafPort,
  4567. call this procedure and then dispose of the grafPort (with a DISPOSE of
  4568. the grafPtr).
  4569.  
  4570. (eye)
  4571.     If you do not call ClosePort before disposing of the
  4572.     grafPort, the memory used by the visRgn and clipRgn will
  4573.     be unrecoverable.
  4574.  
  4575. (eye)
  4576.     After calling ClosePort, be sure not use any copies of
  4577.     the visRgn or clipRgn handles that you may have made.
  4578.  
  4579.  
  4580. \ SetPort
  4581. 2
  4582. Procedure SetPort (gp: GrafPtr);
  4583.  
  4584.     SetPort sets the grafPort indicated by gp to be the current port.
  4585. The global pointer thePort always points to the current port. All
  4586. QuickDraw drawing routines affect the bitMap thePort^.portBits and use
  4587. the local coordinate system of thePort^. Note that OpenPort and
  4588. InitPort do a SetPort to the given port.
  4589.  
  4590. (eye)
  4591.     Never do a SetPort to a port that has not been opened
  4592.     with OpenPort.
  4593.  
  4594.     Each port possesses its own pen and text characteristics which
  4595. remain unchanged when the port is not selected as the current port.
  4596.  
  4597.  
  4598. \ GetPort
  4599. 2
  4600. Procedure GetPort (VAR gp: GrafPtr);
  4601.  
  4602.     GetPort returns a pointer to the current grafPort. If you have a
  4603. program that draws into more than one grafPort, it's extremely useful
  4604. to have each procedure save the current grafPort (with GetPort), set
  4605. its own grafPort, do drawing or calculations, and then restore the
  4606. previous grafPort (with SetPort). The pointer to the current grafPort
  4607. is also available through the global pointer thePort, but you may
  4608. prefer to use GetPort for better readability of your program text. For
  4609. example, a procedure could do a GetPort (savePort) before setting its
  4610. own grafPort and a SetPort (savePort) afterwards to restore the
  4611. previous port.
  4612.  
  4613.  
  4614. \ GrafDevice
  4615. 2
  4616. Procedure GrafDevice (device: INTEGER);
  4617.  
  4618.     GrafDevice sets thePort^.device to the given number, which
  4619. identifies the logical output device for this grafPort. The Font
  4620. Manager uses this information. The initial device number is Ø, which
  4621. represents the Macintosh screen.
  4622.  
  4623. \ SetPortBits
  4624. 2
  4625. Procedure SetPortBits (bm: BitMap);
  4626.  
  4627.     SetPortBits sets the Port^.portBits to any previously defined
  4628. bitMap. This allows you to perform all normal drawing and calculations
  4629. on a buffer other than the Macintosh screen -- for example, a 64Ø-by-7
  4630. output buffer for a C. Itoh printer, or a small off-screen image for
  4631. later "stamping" onto the screen.
  4632.  
  4633.     Remember to prepare all fields of the bitMap before you call
  4634. SetPortBits.
  4635.  
  4636.  
  4637. \ PortSize
  4638. 2
  4639. Procedure PortSize (width, height:  INTEGER);
  4640.  
  4641.     PortSize changes the size of the current grafPort's portRect. THIS
  4642. DOES NOT AFFECT THE SCREEN; it merely changes the size of the "active
  4643. area" of the grafPort.
  4644.  
  4645. (hand)
  4646.     This procedure is normally called only by the Window
  4647.     Manager.
  4648.  
  4649.     The top left corner of the portRect remains at its same location;
  4650. the width and height of the portRect are set to the given width and
  4651. height. In other words, PortSize moves the bottom right corner of the
  4652. portRect to a position relative to the top left corner.
  4653.  
  4654.     PortSize does not change the clipRgn or the visRgn, nor does it
  4655. affect the local coordinate system of the grafPort: it changes only the
  4656. portRect's width and height. Remember that all drawing occurs only in
  4657. the intersection of the portBits.bounds  and the portRect, clipped to
  4658. the visRgn and the clipRgn.
  4659.  
  4660.  
  4661. \ MovePortTo
  4662. 2
  4663. Procedure MovePortTo (leftGlobal,topGlobal: INTEGER);
  4664.  
  4665.     MovePortTo changes the position of the current grafPort's portRect.
  4666. THIS DOES NOT AFFECT THE SCREEN; it merely changes the location at
  4667. which subsequent drawing inside the port will appear.
  4668.  
  4669. (hand)
  4670.     This procedure is normally called only by the Window
  4671.     Manager.
  4672.  
  4673.     The leftGlobal and topGlobal parameters set the distance between the
  4674. top left corner of portBits.bounds and the top left corner of the new
  4675. portRect. For example,
  4676.  
  4677.     MovePortTo(256,171);
  4678.  
  4679. will move the top left corner of the portRect to the center of the
  4680. screen (if portBits is the Macintosh screen) regardless of the local
  4681. coordinate system.
  4682.  
  4683. Like PortSize, MovePortTo does not change the clipRgn or the visRgn,
  4684. nor does it affect the local coordinate system of the grafPort.
  4685.  
  4686.  
  4687. \ SetOrigin
  4688. 2
  4689. Procedure SetOrigin (h,v: INTEGER);
  4690.  
  4691.     SetOrigin changes the local coordinate system of the current
  4692. grafPort. THIS DOES NOT AFFECT THE SCREEN; it does, however, affect
  4693. where subsequent drawing and calculation will appear in the grafPort.
  4694. SetOrigin updates the coordinates of the portBits.bounds, the portRect,
  4695. and the visRgn. All subsequent drawing and calculation routines will
  4696. use the new coordinate system.
  4697.  
  4698.     The h and v parameters set the coordinates of the top left corner of
  4699. the portRect. All other coordinates are calculated from this point.
  4700. All relative distances among any elements in the port will remain the
  4701. same; only their absolute local coordinates will change.
  4702.  
  4703. (hand)
  4704.     SetOrigin does not update the coordinates of the clipRgn
  4705.     or the pen; these items stick to the coordinate system
  4706.     (unlike the port's structure, which sticks to the
  4707.     screen).
  4708.  
  4709.     SetOrigin is useful for adjusting the coordinate system after a
  4710. scrolling operation. (See ScrollRect under "Bit Transfer Operations"
  4711. below.)
  4712.  
  4713.  
  4714. \ SetClip
  4715. 2
  4716. Procedure SetClip (rgn: RgnHandle);
  4717.  
  4718.     SetClip changes the clipping region of the current grafPort to a
  4719. region equivalent to the given region. Note that this does not change
  4720. the region handle, but affects the clipping region itself. Since SetClip
  4721. makes a copy of the given region, any subsequent changes you make to
  4722. that region will not affect the clipping region of the port.
  4723.  
  4724.     You can set the clipping region to any arbitrary region, to aid you
  4725. in drawing inside the grafPort. The initial clipRgn is an arbitrarily
  4726. large rectangle.
  4727.  
  4728.  
  4729. \ GetClip
  4730. 2
  4731. Procedure GetClip (rgn: RgnHandle);
  4732.  
  4733.     GetClip changes the given region to a region equivalent to the
  4734. clipping region of the current grafPort. This is the reverse of what
  4735. SetClip does. Like SetClip, it does not change the region handle.
  4736.  
  4737.  
  4738. \ ClipRect
  4739. 2
  4740. Procedure ClipRect (r: Rect);
  4741.  
  4742.     ClipRect changes the clipping region of the current grafPort to a
  4743. rectanble equivalent to given rectangle. Note that this does not
  4744. change the region handle, but affects the region itself.
  4745.  
  4746.  
  4747. \ BackPat
  4748. 2
  4749. Procedure BackPat (pat: Pattern);
  4750.  
  4751.     BackPat sets the background pattern of the current grafPort to the
  4752. given pattern. The background pattern is used in ScrollRect and in all
  4753. QuickDraw routines that perform an "erase" operation.
  4754.  
  4755.  
  4756.  
  4757.  
  4758. \ InitCursor
  4759. 2
  4760. Procedure InitCursor;
  4761.  
  4762.     InitCursor sets the current cursor to the predefined arrow cursor,
  4763. an arrow pointing north-northwest, and sets the CURSOR LEVEL to Ø,
  4764. making the cursor visible. The cursor level, which is initialized to Ø
  4765. when the system is booted, keeps track of the number of times the cursor
  4766. has been hidden to compensate for nested calls to HideCursor and
  4767. ShowCursor (below).
  4768.  
  4769.     Before you call InitCursor, the cursor is undefined (or, if set by a
  4770. previous process, it's whatever that process set it to).
  4771.  
  4772.  
  4773. \ SetCursor
  4774. 2
  4775. Procedure SetCursor (crsr: Cursor);
  4776.  
  4777.     SetCursor sets the current cursor to the 16-by-16-bit image in crsr.
  4778. If the cursor is hidden, it remains hidden and will attain the new
  4779. appearnce when it's uncovered; if the cursor is already visible, it
  4780. changes to the new appearance immediately.
  4781.  
  4782.     The cursor image is initialized by InitCursor to a north-northwest
  4783. arrow, visible on the screen. There is no way to retrieve the current
  4784. cursor image.
  4785.  
  4786. \ HideCursor
  4787. 2
  4788. Procedure HideCursor;
  4789.  
  4790.     HideCursor removes the cursor from the screen, restoring the bits
  4791. under it, and decrements the cursor level (which InitCursor initialized
  4792. to Ø). Every call to HideCursor should be balanced by a subsequent call
  4793. to ShowCursor.
  4794.  
  4795.  
  4796. \ ShowCursor
  4797. 2
  4798. Procedure ShowCursor;
  4799.  
  4800.     ShowCursor increments the cursor level, which may have been
  4801. decremented by HideCursor, and displays the cursor on the screen if the
  4802. level becomes Ø. A call to ShowCursor should balance each previous call
  4803. to HideCursor. The level is not incremented beyond Ø, so extra calls to
  4804. ShowCursor don't hurt.
  4805.  
  4806.     QuickDraw low-level interrupt-driven routines link the cursor with
  4807. the mouse position, so that if the cursor level is Ø (visible), the
  4808. cursor automatically follows the mouse. You don't need to do anything
  4809. but a ShowCursor to have a cursor track the mouse. There is  no way to
  4810. "disconnect" the cursor from the mouse; you can't force the cursor to a
  4811. certain position, nor can you easily prevent the cursor from entering a
  4812. certain area of the screen.
  4813.  
  4814.     If the cursor has been changed (with SetCursor) while hidden,
  4815. ShowCursor presents the new cursor.
  4816.  
  4817.     The cursor is initialized by InitCursor to a north-northwest arrow,
  4818. not hidden.
  4819.  
  4820.  
  4821. \ ObscureCursor
  4822. 2
  4823. Procedure ObscureCursor;
  4824.  
  4825.     ObscureCursor hides the cursor until the next time the mouse is
  4826. moved. Unlike HideCursor, it has no effect on the cursor level and must
  4827. not be balanced by a call to ShowCursor.
  4828.  
  4829. \ HidePen
  4830. 2
  4831. Procedure HidePen
  4832.  
  4833.     HidePen decrements the current grafPort's pnVis field, which is
  4834. initialized to Ø by OpenPort; whenever pnVis is negative, the pen does
  4835. not draw on the screen. PnVis keeps track of the number of times the
  4836. pen has been hidden to compensate for nested calls to HidePen and
  4837. ShowPen (below). HidePen is called by OpenRgn, OpenPicture, and
  4838. OpenPoly so that you can define regions, pictures, and polygons without
  4839. drawing on the screen.
  4840.  
  4841. \ ShowPen
  4842. 2
  4843. Procedure ShowPen;
  4844.  
  4845.     ShowPen increment the current grafPort's pnVis field, which may have
  4846. been decremented by HidePen; if pnVis becomes Ø, QuickDraw resumes
  4847. drawing on the screen. Extra calls to ShowPen will increment pnVis
  4848. beyond Ø, so every call to ShowPen should be balanced by a subsequent
  4849. call to HidePen. ShowPen is called by CloseRgn, ClosePicture, and
  4850. ClosePoly.
  4851. \ GetPen
  4852. 2
  4853. Procedure GetPen (VAR pt: Point);
  4854.  
  4855.     GetPen returns the current pen location, in the local coordinates of
  4856. the current grafPort.
  4857. \ GetPenState
  4858. 2
  4859. Procedure GetPenState (VAR pnState: PenState);
  4860.  
  4861.     GetPenState saves the pen location, size, pattern, and mode into a
  4862. storage variable, to be restored later with SetPenState (below). This
  4863. is useful when calling short subroutines that operate in the current
  4864. port but must change the graphics pen: each such procedure can save
  4865. the pen's state when it's called, do whatever it needs to do, and
  4866. restore the previous pen state immediately before returning.
  4867.  
  4868.     The PenState data type is not useful for anything except saving the
  4869. pen's state.
  4870. \ SetPenState
  4871. 2
  4872. Procedure SetPenState (pnState: PenState);
  4873.  
  4874.     SetPenState sets the pen location, size, pattern, and mode in the
  4875. current grafPort to the values stored in pnState. This is usually
  4876. called at the end of a procedure that has altered the pen parameters
  4877. and wants to restore them to their state at the beginning of the
  4878. Procedure. (See GetPenState, above.)
  4879. \ PenSize
  4880. 2
  4881. Procedure PenSize (width, height: INTEGER);
  4882.  
  4883.     PenSize sets the dimensions of the graphics pen in the current
  4884. grafPort. All subsequent calls to Line, LineTo, and the procedures
  4885. that draw framed shapes in the current grafPort will use the new pen
  4886. dimensions.
  4887.  
  4888.     The pen dimensions can be accessed in the variable thePort^.pnSize,
  4889. which is of type Point. If either of the pen dimensions is set to a
  4890. negative value, the pen assumes the dimensions (Ø,Ø) and no drawing is
  4891. performed. For a discussion of how the pen draws, see the "General
  4892. Discussion of Drawing" earlier in this manuel.
  4893. \ PenMode
  4894. 2
  4895. Procedure PenMode (mode: INTEGER);
  4896.  
  4897.     PenMode sets the transfer mode through which the pnPat is
  4898. transferred onto the bitMap when lines or shapes are drawn. The mode
  4899. may be any one of the pattern transfer modes:
  4900.  
  4901.     patCopy     patXor      notPatCopy  notPatXor
  4902.     patOr       patBic      notPatOr    notPatBic
  4903.  
  4904.     If the mode is one of the source transfer modes (or negative), no
  4905. drawing is performed. The current pen mode can be obtained in the
  4906. variable thePort^.pnMode. The initial pen mode is patCopy, in which
  4907. the pen pattern is copied directly to the bitMap.
  4908. \ PenPat
  4909. 2
  4910. Procedure PenPat (pat: Pattern);
  4911.  
  4912.     PenPat sets the pattern that is used by the pen in the current
  4913. grafPort. The standard patterns white, black, gray, ltGray and dkGray
  4914. are predefined; the initial pnPat is black. The current pen pattern
  4915. can be obtained in the variable thePort^.onPat, and this value can be
  4916. assigned (but not compared!) to any other variable of type Pattern.
  4917. \ PenNormal
  4918. 2
  4919. Procedure PenNormal;
  4920.  
  4921.     PenNormal resets the initial state of the pen in the current
  4922. grafPort, as follows:
  4923.  
  4924.     Field       Setting
  4925.     -----           -------
  4926.     pnSize      (1,1)
  4927.     pnMode      patCopy
  4928.     pnPat       black
  4929.  
  4930.     The pen location is not changed.
  4931. \ MoveTo
  4932. 2
  4933. Procedure MoveTo (h,v: INTEGER);
  4934.  
  4935.     MoveTo moves the pen to location  (h,v) in the local coordinates of
  4936. the current grafPort. No drawing is performed.
  4937. \ Move
  4938. 2
  4939. Procedure Move (dh,dv: INTEGER);
  4940.  
  4941.     This procedure moves the pen a distance of dh horizontally and dv
  4942. vertically from its current location; it calls MoveTo(h+dh,v+dv), where
  4943. (h,v) is the current location,  The positive directions are to the
  4944. right and down. No drawing is performed.
  4945. \ LineTo
  4946. 2
  4947. Procedure LineTo (h,v: INTEGER);
  4948.  
  4949.     LineTo draws a line from the current pen location to the location
  4950. specified (in local coordinates) by h and v. The new pen location is
  4951. (h,v) after the line is drawn. See the general discussion of drawing.
  4952.  
  4953.     If a region or polygon is open and being formed, its outline is
  4954. infinitely thin and is not affected by the pnSize, pnMode, or pnPat.
  4955. (See OpenRgn and OpenPoly.)
  4956. \ Line
  4957. 2
  4958. Procedure Line (dh,dv: INTEGER);
  4959.  
  4960.     This procedure draws a line to the location that is a distance of dh
  4961. horizontally and dv vertically from the current pen location; it calls
  4962. LineTo(h+dh,v+dv), where (h,v) is the current location. The positive
  4963. directions are to the right and down. The pen location becomes the
  4964. coordinates of the end of the line after the line is drawn. See the
  4965. general discussion of drawing.
  4966.  
  4967.     If a region or polygon is open and being formed, its outline is
  4968. infinitely thin and is not affected by the pnSize, pnMode, or pnPat.
  4969. (See OpenRgn and OpenPoly.)
  4970. \ TextFont
  4971. 2
  4972. Procedure TextFont (font:INTEGER);
  4973.  
  4974.     TextFont sets the current grafPort's font (thePort^.txFont) to the
  4975. given font number. The initial font number is Ø, which represents the
  4976. system font.
  4977. \ TextFace
  4978. 2
  4979. Procedure TextFace (face:Style);
  4980.  
  4981.     TextFace sets the current grafPort's character style
  4982. (thePort^.txFace). The Style data type allows you to specify a set of
  4983. one or more of the following predefined constants: bold, italic,
  4984. underline, outline, shadow, condense, and extend. For example:
  4985.  
  4986.     TextFace([bold])                    {bold}
  4987.     TextFace([bold,italic]);            {bold and italic}
  4988.     TextFact(thePort^.txFace+[bold]);   {whatever it was plus bold}
  4989.     TextFace(thePort^.txFace-[bold]);   {whatever it was but not bold}
  4990.     TextFace([]);                       {normal}
  4991. \ TextMode
  4992. 2
  4993. Procedure TextMode (mode: INTEGER);
  4994.  
  4995.     TextMode sets the current grafPort's transfer mode for drawing text
  4996. (thePort^.txMode). The mode should be srcOr, srcXor, or srcBic. The
  4997. initial transfer mode for drawing text is srcOR.
  4998. \ TextSize
  4999. 2
  5000. Procedure TextSize (size: INTEGER);
  5001.  
  5002.     TextSize sets the current grafPort's type size (thePort^.txSize) to
  5003. the given number of points. Any size may be specified, but the result
  5004. will look best if the Font Manager has the font in that size (otherwise
  5005. it will scale a size it does have). The next best result will occur if
  5006. the given state is an even multiple of a size available for the font.
  5007. If Ø is specified, the Font Manager will choose one of the available
  5008. sizes -- whichever is closest to the system font size. The initial
  5009. txSize setting is Ø.
  5010. \ SpaceExtra
  5011. 2
  5012. Procedure SpaceExtra (extra: fixed);
  5013.  
  5014.     SpaceExtra sets the current grafPort's spExtra field, which
  5015. specifies the number of pixels by which to widen each space in a line of
  5016. text. This is useful when text is being fully justified (that is,
  5017. aligned with both a left and a right margin). Consider, for example, a
  5018. line that contains three spaces; if there would normally be six pixels
  5019. between the end of the line and the right margin, you would call
  5020. SpaceExtra(2) to print the line with full justification. The initial
  5021. spExtra setting is Ø.
  5022.  
  5023. (hand)
  5024.     Space Extra will also take a negative argument, but be
  5025.     careful not to narrow spaces so much that the text is
  5026.     unreadabe.
  5027.  
  5028.  
  5029. \ DrawChar
  5030. 2
  5031. Procedure DrawChar (ch: CHAR);
  5032.  
  5033.     DrawChar places the given character to the right of the pen
  5034. location, with the left end of its base line at the pen's location, and
  5035. advances the pen accordingly. If the character is not in the font, the
  5036. font's  missing symbol is drawn.
  5037. \ DrawString
  5038. 2
  5039. Procedure DrawString (s: Str255);
  5040.  
  5041.     DrawString performs consecutive calls to DrawChar for each character
  5042. in the supplied string; the string is placed beginning at the current
  5043. pen location and extending right. No formatting (carriage returns, line
  5044. feeds, etc.)  is performed by QuickDraw. The pen location ends up to
  5045. the right of the last character in the string.
  5046. \ DrawText
  5047. 2
  5048. Procedure DrawText (textBuf: QDPtr; firstByte,byteCount: INTEGER);
  5049.  
  5050.     DrawText draws text from an arbitrary structure in memory specified
  5051. by textBuf, starting first Byte bytes into the structure and continuing
  5052. for byteCount bytes. The string of text is placed beginning at the
  5053. current pen location and extending right. No formatting (carriage
  5054. returns, line feeds, etc.) is performed by QuickDraw. The pen location
  5055. ends up to the right of the last character in the string.
  5056. \ CharWidth
  5057. 2
  5058. Function CharWidth (ch: CHAR) : INTEGER;
  5059.  
  5060.     CharWidth returns the value that will be added to the pen horizontal
  5061. coordinate if the specified character is drawn. CharWidth includes the
  5062. effects of the stylistic variations set with TextFace; if you change
  5063. these after determining the character width but before actually drawing
  5064. the character, the  predetermined width may not be correct. If the
  5065. character is a space, CharWidth also includes the effect of SpaceExtra.
  5066. \ StringWidth
  5067. 2
  5068. Function StringWidth (s: Str255 ) : INTEGER;
  5069.  
  5070.     StringWidth returns the width of the given text string, which it
  5071. calculates by adding the CharWidths of all the characters in the string
  5072. (see above). This value will be added to the pen horizontal coordinate
  5073. if the specified string is drawn.
  5074. \ TextWidth
  5075. 2
  5076. Function TextWidth (textBuf: QDPtr; firstByte,byteCount: INTEGER) :
  5077.     INTEGER;
  5078.  
  5079.     TextWidth returns the width of the text stored in the arbitrary
  5080. structure in memory specified by textBuf, starting firstByte bytes into
  5081. the structure and continuing for byteCount bytes. It calculates the
  5082. width by adding the CharWidths of all the characters in the text. (See
  5083. CharWidth, above.)
  5084. \ GetFontInfo
  5085. 2
  5086. Procedure GetFontInfo (VAR info: FontInfo);
  5087.  
  5088.     GetFontInfo returns the following information about the current
  5089. grafPort's character font, taking into consideration the style and size
  5090. in which the characters will be drawn:  the ascent, descent, maximum
  5091. character width (the greatest distance the pen will move when a
  5092. character is drawn), and leading (the vertical distance between the
  5093. descent line and the ascent line below it), all in pixels. The
  5094. FontInfo data structure is defined as:
  5095.  
  5096.     TYPE FontInfo = RECORD
  5097.             ascent:  INTEGER;
  5098.             descent: INTEGER;
  5099.             widMax:  INTEGER;
  5100.             leading: INTEGER;
  5101.           END;
  5102. \ Forecolor
  5103. 2
  5104. Procedure ForeColor (color: LongInt);
  5105.  
  5106.     ForeColor sets the foreground color for all drawing in the current
  5107. grafPort (^thePort.fgColor) to the given color. The following standard
  5108. colors are predefined:  blackColor, whiteColor, redColor, greenColor,
  5109. blueColor, cyanColor, magentaColor, and yellowColor. The initial
  5110. foreground color is blackColor.
  5111. \ BackColor
  5112. 2
  5113. Procedure BackColor (color: LongInt)
  5114.  
  5115.     BackColor sets the background color for all drawing in the current
  5116. grafPort (^thePort.bkColor) to the given color.  Eight standard colors
  5117. are predefined (see ForeColor above). The initial background color is
  5118. whiteColor.
  5119. \ ColorBit
  5120. 2
  5121. Procedure ColorBit (whichBit: INTEGER);
  5122.  
  5123.     ColorBit is called by printing software for a color printer, or
  5124. other color-imaging software, to set the current grafPort's colrBit
  5125. field to whichBit; this tells QuickDraw which plane of the color picture
  5126. to draw into. QuickDraw will draw into the plane corresponding to bit
  5127. number whichBit. Since QuickDraw can support output devices that have
  5128. up to 32 bits of color information per pixel, the possible range of
  5129. values for whichBit is Ø through 31. The initial value of the colrBit
  5130. field is Ø.
  5131. \ SetRect
  5132. 2
  5133. Procedure SetRect (VAR r: Rect; left,top,right, bottom: INTEGER);
  5134.  
  5135.     SetRect assigns the four boundary coordinates to the rectangle. The
  5136. result is a rectangle with coordinates (left,top,right,bottom).
  5137.  
  5138.     This procedure is supplied as a utility to help you shorten your
  5139. program text. If you want a more readable text at the expense of
  5140. length, you can assign integers (or points) directly into the
  5141. rectangle's fields. There is no significant code size or execution
  5142. speed advantage to either method; one's just easier to write, and the
  5143. other's easier to read.
  5144. \ OffSetRect
  5145. 2
  5146. Procedure OffsetRect (VAR r: Rect; dh,dv: INTEGER);
  5147.  
  5148.     OffsetRect moves the rectangle by adding dh to each horizontal
  5149. coordinate and dv to each vertical coordinate. If dh and dv are
  5150. positive, the movement is to the right and down; if either is negative,
  5151. the corresponding movement is in the opposite direction. The rectangle
  5152. retains its shape and size; it's merely moved on the coordinate plane.
  5153. This does not affect the screen unless you subsequently call a routine
  5154. to draw within the rectangle.
  5155. \ InsetRect
  5156. 2
  5157. Procedure InsetRect (VAR r: Rect; dh,dv: INTEGER);
  5158.  
  5159.     InsetRect shrinks or expands the rectangle. The left and right
  5160. sides are moved in by the amount specified by dh; the top and bottom are
  5161. moved towards the center by the amount specified by dv. If dh or dv is
  5162. negative, the appropriate pair of sides is moved outwards instead of
  5163. inwards.  The effect is to alter the size by 2*dh horizontally and 2*dv
  5164. vertically, with the rectangle remaining centered in the same place on
  5165. the coordinate plane.
  5166.  
  5167.     If the resulting width or height becomes less than 1, the rectangle
  5168. is set to the empty rectangle (Ø,Ø,Ø,Ø).
  5169. \ SectRect
  5170. 2
  5171. Function SectRect(srcRectA,srcRectB: Rect; VAR dstRect: Rect) :
  5172.     BOOLEAN;
  5173.  
  5174.     SectRect calculates the rectangle that is the intersection of the
  5175. two input rectangles, and returns TRUE if they indeed intersect or FALSE
  5176. if they do not. Rectangles that "touch" at a line or a point are not
  5177. considered intersecting, because their intersection rectangle (really,
  5178. in this case, an intersection line or point) does not enclose any bits
  5179. on the bitMap.
  5180.  
  5181.     If the rectangles do not intersect, the destination rectangle is set
  5182. to (Ø,Ø,Ø,Ø,). SectRect works correctly even if one of the source
  5183. rectangles is also the destination.
  5184. \ UnionRect
  5185. 2
  5186. Procedure UnionRect (srcRectA,srcRectB: Rect; VAR dstRect: Rect);
  5187.  
  5188.     Union Rect calculates the smallest rectangle which encloses both
  5189. input rectangles. It works correctly even if one of the source
  5190. rectangles is also the destination.
  5191. \ PtInRect
  5192. 2
  5193. Function PtInRect (pt: Point; r: Rect) : BOOLEAN;
  5194.  
  5195.     PtInRect determines whether the pixel below and to the right of the
  5196. given coordinate point is enclosed in the specified rectangle, and
  5197. returns TRUE if so or FALSE if not.
  5198. \ Pt2Rect
  5199. 2
  5200. Procedure Pt2Rect (ptA,ptB: Point; VAR dstRect: Rect);
  5201.  
  5202.     Pt2Rect returns the smallest rectangle which encloses the two input
  5203. points.
  5204. \ PtToAngle
  5205. 2
  5206. Procedure PtToAngle (r: Rect; pt: Point; VAR angle: INTEGER);
  5207.  
  5208.     PtToAngle calculates an integer angle between a line from the center
  5209. of the rectangle to the given point and a line from the center of the
  5210. rectangle pointing straight up (12 o'clock high). The angle is in
  5211. degrees from Ø to 359, measured clockwise from 12 o'clock, with 9Ø
  5212. degrees at 3 o'clock, 18Ø at 6o'clock, and 27Ø at 9 o'clock. Other
  5213. angles are measured relative to the rectangle: if the line to the
  5214. given point goes through the top right corner of the rectangle, the
  5215. angle returned is 45 degrees, even if the rectangle is not square; if
  5216. it goes through the bottom right corner, the angle is 135 degrees, and
  5217. so on (see Figure 18).
  5218.  
  5219.     The angle returned might be used as input to one of the procedures
  5220. that manipulate arcs and wedges, as described below under "Graphic
  5221. Operations on Arcs and Wedges".
  5222. \ EqualRect
  5223. 2
  5224. Function EqualRect (rectA,rectB: Rect) : BOOLEAN;
  5225.  
  5226.     EqualRect compares the two rectangles and returns TRUE if they are
  5227. equal or FALSE if not. The two rectangles must have identical boundary
  5228. coordinates to be considered equal.
  5229.  
  5230.  
  5231. \ EmptyRect
  5232. 2
  5233. Function EmptyRect (r: Rect) : BOOLEAN;
  5234.  
  5235.     EmptyRect returns TRUE if the given rectangle is an empty rectangle
  5236. or FALSE if not. A rectangle is considered empty if the bottom
  5237. coordinate is equal to or less than the top or the right coordinate is
  5238. equal to or less than the left.
  5239. \ FrameRect
  5240. 2
  5241. Procedure FrameRect (r: Rect);
  5242.  
  5243.     FrameRect draws a hollow outline just inside the specified rectangle
  5244. using the current grafPort's pen pattern, mode, and size. The outline
  5245. is as wide as the pen width and as tall as the pen height. It is drawn
  5246. with the pnPat, according to the pattern transfer mode specified by
  5247. pnMode. The pen location is not changed by this procedure.
  5248.  
  5249.     If a region is open and being formed, the outside outline of the new
  5250. rectangle is mathematically added to the region's boundary.
  5251. \ PaintRect
  5252. 2
  5253. Procedure PaintRect (r: Rect);
  5254.  
  5255.     PaintRect paints the specified rectangle with the current grafPort's
  5256. pen pattern and mode. The rectangle on the bitMap is filled with the
  5257. pnPat, according to the pattern transfer mode specified by pnMode. The
  5258. pen location is not changed by this procedure.
  5259. \ EraseRect
  5260. 2
  5261. Procedure EraseRect (r: Rect);
  5262.  
  5263.     EraseRect paints the specified rectangle with the current grafPort's
  5264. background pattern bkPat (in patCopy mode). The grafPort's pnPat and
  5265. pnMode are ignored; the pen location is not changed.
  5266. \ InvertRect
  5267. 2
  5268. Procedure InvertRect (r: Rect);
  5269.  
  5270.     __________________________________________________________________
  5271.       Assembly-Language note: The macro you invoke to call InvertRect
  5272.       from  assembly language is named _InverRect.
  5273.     __________________________________________________________________
  5274.  
  5275.     InvertRect inverts the pixels enclosed by the specified rectangle:
  5276. every white pixel becomes black and every black pixel becomes white.
  5277. The grafPort's pnPat, pnMode, and bkPat are all ignored; the pen
  5278. location is not changed.
  5279. \ FillRect
  5280. 2
  5281. Procedure FillRect (r: Rect; pat: Pattern);
  5282.  
  5283.     FillRect fills the specified rectangle with the given pattern (in
  5284. patCopy mode). The grafPort's pnPat, pnMode, and bkPat are all
  5285. ignored; the pen location is not changed.
  5286. \ FrameOval
  5287. 2
  5288. Procedure FrameOval (r: Rect);
  5289.  
  5290.     FrameOval draws a hollow outline just inside the oval that fits
  5291. inside the specified rectangle, using the current grafPort's pen
  5292. pattern, mode, and size. The outline is as wide as the pen width and as
  5293. tall as the pen height. It is drawn with the pnPat, according to the
  5294. pattern transfer mode specified by pnMode. The pen location is not
  5295. changed by this procedure.
  5296.  
  5297.     If a region is open and being formed, the outside outline of the new
  5298. oval is mathematically added to the region's boundary.
  5299. \ PaintOval
  5300. 2
  5301. Procedure PaintOval (r: Rect);
  5302.  
  5303.     PaintOval paints an oval just inside the specified rectangle with
  5304. the current grafPort's pen pattern and mode. The oval on the bitMap is
  5305. filled with the pnPat, according to the pattern transfer mode specified
  5306. by pnMode. The pen location is not changed by this procedure.
  5307. \ EraseOval
  5308. 2
  5309. Procedure EraseOval (r: Rect);
  5310.  
  5311.     EraseOval paints an oval just inside the specified rectangle with
  5312. the current grafPort's background pattern bkPat (in patCopy mode). The
  5313. grafPort's pnPat and pnMode are ignored; the pen location is not
  5314. changed.
  5315. \ InvertOval
  5316. 2
  5317. Procedure InvertOval (r: Rect);
  5318.  
  5319.     InvertOval inverts the pixels enclosed by an oval just inside the
  5320. specified rectangle: every white pixel becomes black and every black
  5321. pixel becomes white. The grafPort's pnPat, pnMode, and bkPat are all
  5322. ignored; the pen location is not changed.
  5323. \ FillOval
  5324. 2
  5325. Procedure FillOval (r: Rect; pat: Pattern);
  5326.  
  5327.     FillOval fills an oval just inside the specified rectangle with the
  5328. given pattern in patCopy mode). The grafPort's pnPat, pnMode, and
  5329. bkPat are all ignored; the pen location is not changed.
  5330. \ FrameRoundRect
  5331. 2
  5332. Procedure FrameRoundRect (r: Rect; ovalWidth,ovalHeight: INTEGER);
  5333.  
  5334.     FrameRoundRect draws a hollow outline just inside the specified
  5335. rounded-corner rectangle, using the current grafPort's pen pattern,
  5336. mode, and size. OvalWidth and ovalHeight specify the diameters of
  5337. curvature for the corners (see Figure 19). The outline is as wide as
  5338. the pen width and as tall as the pen height. It is drawn with the
  5339. pnPat, according to the pattern transfer mode specified by pnMode. The
  5340. pen location is not changed by this procedure.
  5341.  
  5342.     If a region is open and being formed, the outside outline of the new
  5343. rounded-corner rectangle is mathematically added to the region's
  5344. boundary.
  5345. \ PaintRoundRect
  5346. 2
  5347. Procedure PaintRoundRect (r: Rect; ovalWidth,ovalHeight: INTEGER);
  5348.  
  5349.     PaintRoundREct paints the specified rounded-corner rectangle with
  5350. the current grafPort's pen pattern and mode. OvalWidth and ovalHeight
  5351. specify the diameters of curvature for the corners. The rounded-corner
  5352. rectangle on the bitMap is filled with the pnPat, according to the
  5353. pattern transfer mode specified by pnMode. The pen location is not
  5354. changed by this procedure.
  5355. \ EraseRoundRect
  5356. 2
  5357. Procedure EraseRoundRect (r: Rect; ovalWidth,ovalHeight: INTEGER);
  5358.  
  5359.     EraseRoundRect paints the specified rounded-corner rectangle with
  5360. the current grafPort's background pattern bkPat (in patCopy mode).
  5361.  
  5362.     OvalWidth and ovalHeight specify the diameters of curvature for the
  5363. corners. The grafPort's pnPat and pnMode are ignored; the pen location
  5364. is not changed.
  5365. \ InvertRoundRect
  5366. 2
  5367. Procedure InvertRoundRect (r: Rect; ovalWidth,ovalHeight: INTEGER);
  5368.  
  5369.     InvertRoundRect inverts the pixels enclosed by the specified
  5370. rounded-corner rectangle: every white pixel becomes black and every
  5371. black pixel becomes white. OvalWidth and ovalHeight specify the
  5372. diameters of curvature for the corners. The grafPort's pnPat, pnMode,
  5373. and bkPat are all ignored; the pen location is not changed.
  5374. \ FillRoundRect
  5375. 2
  5376. Procedure FillRoundRect (r: Rect; ovalWidth,ovalHeight: INTEGER; pat:
  5377.                             Pattern);
  5378.  
  5379.     FillRoundRect fills the specified rounded-corner rectangle with the
  5380. given pattern (in patCopy mode). OvalWidth and ovalHeight specify the
  5381. diameters of curvature for the corners. The grafPort's pnPat, pnMode,
  5382. and bkPat are all ignored; the pen location is not changed.
  5383. \ FrameArc
  5384. 2
  5385. Procedure FrameArc (r: Rect; startAngle,arcAngle: INTEGER);
  5386.  
  5387.     FrameArc draws an arc of the oval that fits inside the specified
  5388. rectangle, using the current grafPort's pen pattern, mode, and size.
  5389. StartAngle indicates where the arc begins and is treated mod 36Ø.
  5390. ArcAngle defines the extent of the arc. The angles are given in
  5391. positive or negative degrees; a positive angle goes clockwise, while a
  5392. negative angle goes counterclockwis. Zero degrees is at l2 o'clock,
  5393. high, 9Ø (or -27Ø) is at 3 o'clock, 18Ø (or -18Ø) is at 6 o'clock, and
  5394. 27Ø (or -9Ø) is at 9 o'clock. Other angles are measured relative to
  5395. the enclosing rectangle:  a line from the center of the rectangle
  5396. through its top right corner is at 45 degrees, even if the rectangle is
  5397. not square; a line through the bottom right corner is at 135 degrees,
  5398. and so on (see Figure 2Ø).
  5399.  
  5400.     The arc is as wide as the pen width and as tall as the pen height.
  5401. It is drawn with the pnPat, according to the pattern transfer mode
  5402. specified by pnMode. The pen location is not changed by this
  5403. Procedure.
  5404.  
  5405. (eye)
  5406.     FrameArc differs from other QuickDraw procedures that
  5407.     frame shapes in that the arc is not mathematically added
  5408.     to the boundary of a region that is open and being
  5409.     formed.
  5410.  
  5411.  
  5412. \ PaintArc
  5413. 2
  5414. Procedure PaintArc (r: Rec; startAngle,arcAngle: INTEGER);
  5415.  
  5416.     PaintArc paints a wedge of the oval just inside the specified
  5417. rectangle with the current grafPort's pen pattern and mode. StartAngle
  5418. and arcAngle define the arc of the wedge as in FrameArc. The wedge on
  5419. the bitMap is filled with the pnPat, according to the pattern transfer
  5420. mode specified by pnMode. The pen location is not changed by this
  5421. Procedure.
  5422.  
  5423.  
  5424. \ EraseArc
  5425. 2
  5426. Procedure EraseArc (r: Rect; startAngle,arcAngle: INTEGER);
  5427.  
  5428.     EraseArc paints a wedge of the oval just inside the specified
  5429. rectangle with the current grafPort's background pattern bkPat (in
  5430. patCopy mode). StartAngle and arcAngle define the arc of the wedge as in
  5431. FrameArc. The grafPort's pnPat and pnMode are ignored; the pen location
  5432. is not changed.
  5433. \ InvertArc
  5434. 2
  5435. Procedure InvertArc (r: Rect; startAngle,arcAngle: INTEGER);
  5436.  
  5437.     InvertArc inverts the pixels enclosed by a wedge of the oval just
  5438. inside the specified rectangle:  every white pixel becomes black and
  5439. every black pixel becomes white. StartAngle and arcAngle define the
  5440. arc of the wedge as in FrameArc. The grafPort's pnPat, pnMode, and
  5441. bkPat are all ignored; the pen location is not changed.
  5442. \ FillArc
  5443. 2
  5444. Procedure FillArc (r: Rect; startAngle,arcAngle: INTEGER; pat:
  5445.     Pattern);
  5446.  
  5447.     FillArc fills a wedge of the oval just inside the specified
  5448. rectangle with the given pattern (in patCopy mode). StartAngle and
  5449. arcAngle define the arc of the wedge as in FrameArc. The grafPort's
  5450. pnPat, pnMode, and bkPat are all ignored; the pen lcoation is not
  5451. changed.
  5452. \ NewRgn
  5453. 2
  5454. Function NewRgn : RgnHandle;
  5455.  
  5456.     NewRgn allocates space for a new, dynamic, variable-size region,
  5457. initializes it to the empty region (Ø,Ø,Ø,Ø), and returns a handle to
  5458. the new region. Only this function creates new regions; all other
  5459. Procedures just alter the size and shape of regions you create.
  5460. OpenPort calls NewRgn to allocate space for the port's visRgn and
  5461. clipRgn.
  5462.  
  5463. (eye)
  5464.     Except when using visRgn or clipRgn, you MUST call NewRgn
  5465.     before specifying a region's handle in any drawing or
  5466.     calculation procedure.
  5467.  
  5468. (eye)
  5469.     Never refer to a region without using its handle.
  5470. \ DisposeRgn
  5471. 2
  5472. Procedure DisposeRgn (rgn: RgnHandle);
  5473.  
  5474.     DisposeRgn deallocates space for the region whose handle is supplied
  5475. and returns the memory used by the region to the free memory pool. Use
  5476. this only after you are completely through with a temporary region.
  5477.  
  5478. (eye)
  5479.     Never use a region once you have deallocated it, or you
  5480.     will risk being hung by dangling pointers!
  5481. \ CopyRgn
  5482. 2
  5483. Procedure CopyRgn (srcRgn,dstRgn: RgnHandle);
  5484.  
  5485.     CopyRgn copies the mathematical structure of arcRgn into dstRgn;
  5486. that is, it makes a duplicate copy of srcRgn. Once this is done, srcRgn
  5487. may be altered (or even disposd of) without affecting dstRgn. COPYRGN
  5488. DOES NOT CREATE THE DESTINATION REGION:  you must use NewRgn to create
  5489. the dstRgn before you call CopyRgn.
  5490. \ SetEmptyRgn
  5491. 2
  5492. Procedure SetEmptyRgn (rgn: RgnHandle);
  5493.  
  5494.     Set EmptyRgn destroys the previous structure of the given region,
  5495. then sets the new structure to the empty region (Ø,Ø,Ø,Ø).
  5496. \ SetRectRgn
  5497. 2
  5498. Procedure SetRectRgn (rgn: RgnHandle; left,top,right,bottom: INTEGER);
  5499.  
  5500.     SetRectRgn destroys the previous structure of the given region, then
  5501. sets the new structure to the rectangle specified by left, top, right,
  5502. and bottom.
  5503.  
  5504.     If the specified rectangle is empty (i.e., left>=right or
  5505. top>=Bottom), the region is set to the empty region (Ø,Ø,Ø,Ø).
  5506. \ RectRgn
  5507. 2
  5508. Procedure RectRgn (rgn: RgnHandle; r: Rect);
  5509.  
  5510.     RectRgn destroys the previous structure of the given region, then
  5511. sets the new structure to the rectangle specified by r. This is
  5512. operationally synonymous with SetRectRgn, except the input rectangle is
  5513. defined by a rectangle rather than by four boundary coordinates.
  5514. \ OpenRgn
  5515. 2
  5516. Procedure OpenRgn;
  5517.  
  5518.     OpenRgn tells QuickDraw to allocate temporary space and start saving
  5519. lines and framed shapes for later processing as a region definition.
  5520. While a region is open, all calls to Line, LineTo, and the procedures
  5521. that draw framed shapes (except arcs) affect the outline of the region.
  5522. Only the line endpoints and shape boundaries affect the region
  5523. definition; the pen mode, pattern, and size do not affect it. In fact,
  5524. OpenRgn calls HidePen, so no drawing occurs on the screen while the
  5525. region is open (unless you called ShowPen just after Open Rgn, or you
  5526. called ShowPen previously without balancing it by a call to HidePen).
  5527. Since the pen hangs below and to the right of the pen location, drawing
  5528. lines with even the smallest pen will change bits that lie outside the
  5529. region you define.
  5530.  
  5531.     The outline of a region is mathematically defined and infinitely
  5532. thin, and separates the bitMap into two groups of bits:  those within
  5533. the region and those outside it. A region should consist of one or more
  5534. closed loops. Each framed shape itself constitutes a loop. Any lines
  5535. drawn with Line or LineTo should connect with each other or with a
  5536. framed shape. Even though  the on-screen presentation of a region is
  5537. clipped, the definition of a region is not; you can define a region
  5538. anywhere on the coordinate plane with complete disregard for the
  5539. location of various grafPort entities on that plane.
  5540.  
  5541.     When a region is open, the current grafPort's rgnSave field contains
  5542. a handle to information related to the region definition. If you want
  5543. to temporarily disable the collection of lines and shapes, you can save
  5544. the current value of this field, set the field to NIL, and later
  5545. restore the saved value to resume the region definition.
  5546.  
  5547. (eye)
  5548.     Do not call OpenRgn while another region is already open.
  5549.     All open regions but the most recent will behave
  5550.     strangely.
  5551. \ CloseRgn
  5552. 2
  5553. Procedure CloseRgn (dstRgn: RgnHandle);
  5554.  
  5555.     CloseRgn stops the collection of lines and framed shapes, organizes
  5556. them into a region definition, and saves the resulting region into the
  5557. region indicated by dstRgn. You should perform one and only one
  5558. CloseRgn for every OpnRgn. CloseRgn calls ShowPen, balancing the
  5559. HidePen call made by OpenRgn.
  5560.  
  5561.     Here's an example of how to create and open a region, define a
  5562. barbell shape, close the region, and draw it:
  5563.  
  5564.     barbell := NewRgn;                  {make a new region}
  5565.     OpenRgn;                            {begin collecting stuff}
  5566.        SetRect(tempRect,2Ø,2Ø,3Ø,5Ø);   {form the left weight}
  5567.        FrameOval(tempRect);
  5568.        SetRect(tempRect,3Ø,3Ø,8Ø,4Ø);   {form the bar}
  5569.        FrameRect(tempRect);
  5570.        SetRect(tempRect(8Ø,2Ø,9Ø,5Ø);   {form the right weight}
  5571.        FrameOval(tempRect);
  5572.     CloseRgn(barbell);                  {we're done; save in barbell}
  5573.     FillRgn(barbell,black);             {draw it on the screen}
  5574.     DisposeRgn(barbell);                {we don't need you anymore...}
  5575. \ OffsetRgn
  5576. 2
  5577. Procedure OffsetRgn (rgn: RgnHandle; dh,dv: INTEGER);
  5578.  
  5579.     OffsetRgn moves the region on the coordinate plane, a distance of dh
  5580. horizontally and dv vertically. This does not affect the screen unless
  5581. you subsequently call a routine to draw the region. If dh and dv are
  5582. positive, the movement is to the right and down; if either is negative,
  5583. the corresponding movement is in the opposite direction. The region
  5584. retains its size and shape.
  5585.  
  5586. (hand)
  5587.     OffsetRgn is an especially efficient operation, because
  5588.     most of the data defining a region is stored relative to
  5589.     rgnBBox and so isn't actually changed by OffsetRgn.
  5590. \ InsetRgn
  5591. 2
  5592. Procedure InsetRgn (rgn: RgnHandle; dh,dv: INTEGER);
  5593.  
  5594.     InsetRgn shrinks or expands the region. All points on the region
  5595. boundary are moved inwards a distance of dv vertically and dh
  5596. horizontally; if dh or dv is negative, the points are moved outwards in
  5597. that direction. InsetRgn leaves the region "centered" at the same
  5598. position, but moves the outline in (for positive values of dh and dv)
  5599. or out (for negative values of dh and dv). InsetRgn of a rectangular
  5600. region works just like InsetRect.
  5601. \ SectRgn
  5602. 2
  5603. Procedure SectRgn (srcRgnA,srcRgnB,dstRgn: RgnHandle);
  5604.  
  5605.     SectRgn calculates the intersection of two regions and places the
  5606. intersection in a third region. THIS DOES NOT CREATE THE DESTINATION
  5607. REGION:  you must use NewRgn to create the dstRgn before you call
  5608. SectRgn. The dstRgn can be one of the source regions, if desired.
  5609.  
  5610.     If the regions do not intersect, or one of the regions is empty, the
  5611. destination is set to the empty region (Ø,Ø,Ø,Ø).
  5612. \ UnionRgn
  5613. 2
  5614. Procedure UnionRgn (srcRgnA,srcRgnB,dstRgn: RgnHandle);
  5615.  
  5616.     UnionRgn calculates the union of two regions and places the union in
  5617. a third region. THIS DOES NOT CREATE THE DESTINATION REGION:  you must
  5618. use NewRgn to create the dstRgn before you call UnionRgn. The dstRgn
  5619. can be one of the source regions, if desired.
  5620.  
  5621.     If both regions are empty, the destination is set to the empty
  5622. region (Ø,Ø,Ø,Ø).
  5623. \ DiffRgn
  5624. 2
  5625. Procedure DiffRgn (srcRgnA,srcRgnB,dstRgn: RgnHandle);
  5626.  
  5627.     DiffRgn subtracts  srcRgnB from srcRgnA and places the difference in
  5628. a third region. THIS DOES NOT CREATE THE DESTINATION REGION:  You must
  5629. use NewRgn to create the dstRgn before you call DiffRgn. The dstRgn
  5630. can be one of the source regions, if desired.
  5631.  
  5632.     If the first source region is empty, the destination is set to the
  5633. empty region (Ø,Ø,Ø,Ø).
  5634. \ XorRgn
  5635. 2
  5636. Procedure XorRgn (srcRgnA,srcRgnB,dstRgn: RgnHandle);
  5637.  
  5638.     XorRgn calculates the difference between the union and the
  5639. intersection of two regions and places the result in a third region.
  5640. THIS DOES NOT CREATE THE DESTINATION REGION:  you must use NewRgn to
  5641. create the dstRgn before you call XorRgn. The dstRgn can be one of the
  5642. source regions, if desired.
  5643.  
  5644.     If the regions are coincident, the destination is set to the empty
  5645. region (Ø,Ø,Ø,Ø).
  5646. \ PtInRgn
  5647. 2
  5648. Function PtInRgn (pt: Point; rgn: RgnHandle) : BOOLEAN;
  5649.  
  5650.     PtInRgn checks whether the pixel below and to the right of the given
  5651. coordinate point is within the specified region, and returns TRUE if so
  5652. or FALSE if not.
  5653. \ RectInRgn
  5654. 2
  5655. Function RectInRgn (r: Rect; rgn: RgnHandle) : BOOLEAN;
  5656.  
  5657.     RectInRgn checks whether the given rectangle intersects the
  5658. specified region, and returns TRUE if the intersection encloses at least
  5659. one bit or FALSE if not.
  5660. \ EqualRgn
  5661. 2
  5662. Function EqualRgn (rgnA,rgnB: RgnHandle) : BOOLEAN;
  5663.  
  5664. EqualRgn compares the two regions and returns TRUE if they are equal
  5665. or FALSE if not. The two regions must have identical sizes, shapes, and
  5666. locations to be considered equal. Any two empty regions are always
  5667. equal.
  5668. \ EmptyRgn
  5669. 2
  5670. Function EmptyRgn (rgn: RgnHandle) : BOOLEAN;
  5671.  
  5672.     EmptyRgn returns TRUE if the region is an empty region or FALSE if
  5673. not. Some of the circumstances in which an empty region can be created
  5674. are: a NewRgn call; a CopyRgn of an empty region; a SetRectRgn or
  5675. RectRegn with an empty rectangle as an argument; CloseRgn without a
  5676. previous OpenRgn or with no drawing after an OpenRgn; OffsetRgn of an
  5677. empty region; InsetRgn with an empty region or too large an inset;
  5678. SectRgn of nonintersecting regions; UnionRgn of two empty regions; and
  5679. DiffRgn or XorRgn of two identical or nonintersecting regions.
  5680. \ FrameRgn
  5681. 2
  5682. Procedure FrameRgn (rgn: RgnHandle);
  5683.  
  5684.     FrameRgn draws a hollow outline just inside the specified region,
  5685. using the current grafPort's pen pattern, mode, and size. The outline
  5686. is as wide as the pen width and as tall as the pen height; under no
  5687. circumstances will the frame go outside the region boundary. The pen
  5688. location is not changed by this procedure.
  5689.  
  5690.     If a region is open and being formed, the outside outline of the
  5691. region being framed is mathematically added to that region's boundary.
  5692. \ PaintRgn
  5693. 2
  5694. Procedure PaintRgn (rgn: RgnHandle);
  5695.  
  5696.     PaintRgn paints the specified region with the current grafPort's pen
  5697. pattern and pen mode. The region on the bitMap is filled with the
  5698. pnPat, according to the pattern transfer mode specified by pnMode. The
  5699. pen location is not changed by this procedure.
  5700. \ EraseRgn
  5701. 2
  5702. Procedure EraseRgn (rgn: RgnHandle);
  5703.  
  5704.     EraseRgn paints the specified region with the current grafPort's
  5705. background pattern bkPat (in patCopy mode). The grafPort's pnPat and
  5706. pnMode are ignored; the pen location is not changed.
  5707. \ InvertRgn
  5708. 2
  5709. Procedure InvertRgn (rgn: RgnHandle);
  5710.  
  5711.     InvertRgn inverts the pixels enclosed by the specified region: every
  5712. white pixel becomes black and every black pixel becomes white. The
  5713. grafPort's pnPat, pnMode, and bkPat are all ignored; the pen lcoation
  5714. is not changed.
  5715. \ FillRgn
  5716. 2
  5717. Procedure FillRgn (rgn: RgnHandle; pat: Pattern);
  5718.  
  5719.     FillRgn fills the specified region with the given pattern (in
  5720. patCopy mode). The grafPort's pnPat, pnMode, and bkPat are all ignored;
  5721. the pen location is not changed.
  5722. \ ScrollRect
  5723. 2
  5724. Procedure ScrollRect (r: Rect; dh,dv: INTEGER; updateRgn: RgnHandle);
  5725.  
  5726.     ScrollRect shifts ("scrolls") those bits inside the intersection of
  5727. the specified rectangle, visRgn, clipRgn, portRect, and portBits.bounds.
  5728. The bits are shifted a distance of dh horizontally and dv vertically.
  5729. The positive directions are to the right and down. No other bits are
  5730. affected. Bits that are shifted out of the scroll area are lost; they
  5731. are neither placed outside the area nor saved. The grafPort's
  5732. background pattern bkPat fills the space created by the scroll. In
  5733. addition, updateRgn is changed to the area filled with bkPat (see
  5734. Figure 21).
  5735.  
  5736.     Figure 21 shows that the pen location after a ScrollRect is in a
  5737. different position relative to what was scrolled in the rectangle. The
  5738. entire scrolled item has been moved to different coordinates. To
  5739. restore it to its coordinates before the ScrollRect, you can use the
  5740. SetOrigin procedure. For example, suppose the dstRect here is the
  5741. portRect of the grafPort and its top left corner is at (95,12Ø).
  5742. SetOrigin(1Ø5,115) will offset the coordinate system to compensate for
  5743. the scroll. Since the clipRgn and pen lcoation are not offset, they
  5744. move down and to the left.
  5745. \ OpenPicture
  5746. 2
  5747. Function  OpenPicture (picFrame: Rect) : PicHandle;
  5748.  
  5749.     OpenPicture returns a hendle to a new picture  which has the given
  5750. rectangle as its picture frame, and tells QuickDraw to start saving as
  5751. the picture definition all calls to drawing routines and all picture
  5752. comments (if any).
  5753.  
  5754.     OpenPicture calls HidePen, so no drawing occurs on the screen while
  5755. the picture is open (unless you call ShowPen just after OpenPicture, or
  5756. you called ShowPen previously without balancing it by a call to HidePen)
  5757.  
  5758.     When a picture is open, the current grafPort's picSave field
  5759. contains a handle to information related to the picture definition. If
  5760. you want to temporarily disable the collection of routine calls and
  5761. picture comments, you can save the current value of this field, set the
  5762. field to NIL, and later restore the saved value to resume the picture
  5763. definition.
  5764.  
  5765. (eye)
  5766.     Do not call OpenPicture while another picture is already
  5767.     open.
  5768. \ ClosePicture
  5769. 2
  5770. Procedure ClosePicture;
  5771.  
  5772.     ClosePicture tells QuickDraw to stop saving routine calls and
  5773. picture comments as the definition of the currently open picture. You
  5774. should perform one and only one ClosePicture for every OpenPicture.
  5775. ClosePicture calls ShowPen, balancing the HidePen call made by
  5776. OpenPicture.
  5777. \ PicComment
  5778. 2
  5779. Procedure PicComment (kind,dataSize: INTEGER; dataHandle: QDHandle);
  5780.  
  5781.     PicComment inserts the specified comment into the definition of the
  5782. currently open picture.  Kind identifies the type of comment.
  5783. DataHandle is a handle to additional data if desired, and dataSize is
  5784. the size of that data in bytes. If there is no additional data for the
  5785. comment, dataHandle should be NIL and dataSize should be Ø. The
  5786. application that processes the comment must include a procedure to do
  5787. the processing and store a pointer to the procedure in the data
  5788. structure pointed to by the grafProcs field of the grafPort (see
  5789. "Customizing QuickDraw Operations").
  5790. \ DrawPicture
  5791. 2
  5792. Procedure DrawPicture (myPicture: PicHandle; dstRect: Rect);
  5793.  
  5794.     DrawPicture draws the given picture to scale in dstRect, expanding
  5795. or shrinking it as necessary to align the borders of the picture frame
  5796. with dstRect. DrawPicture passes any picture comments to the procedure
  5797. accessed indirectly through the grafProcs field of the grafPort (see
  5798. PicComment above).
  5799. \ KillPicture
  5800. 2
  5801. Procedure KillPicture (myPicture: PicHandle);
  5802.  
  5803.     KillPicture deallocates space for the picture whose handle is
  5804. supplied, and returns the memory used by the picture to the free memory
  5805. pool. Use this only when you are completely through with a picture.
  5806. \ OpenPoly
  5807. 2
  5808. Function OpenPoly : PolyHandle;
  5809.  
  5810.     OpenPoly returns a handle to a new polygon and tells QuickDraw to
  5811. start saving the polygon definition as specified by calls to
  5812. line-drawing routines. While a polygon is open, all calls to Line and
  5813. LineTo affect the outline of the polygon. Only the line endpoints
  5814. affect the polygon definition; the pen mode, pattern, and size do not
  5815. affect it. In fact OpenPoly calls HidePen, so no drawing occurs on the
  5816. screen while the polygon is open (unless you call ShowPen just after
  5817. OpenPoly, or you called ShowPen previously without balancing it by a
  5818. call to HidePen).
  5819.  
  5820.     A polygon should consist of a sequence of connected lines. Even
  5821. though the on-screen presentation of a polygon is clipped, the
  5822. definition of a polygon is not; you can define a polygon anywhere on the
  5823. coordinate plane with complete disregard for the location of various
  5824. grafPort entities on that plane.
  5825.  
  5826.     When a polygon is open, the current grafPort's polySave field
  5827. contains a handle to information related to the polygon definition. If
  5828. you want to temprarily disable the polygon definition, you can save the
  5829. current value of this field, set the field to NIL, and later restore the
  5830. saved value to resume the polygon definition.
  5831.  
  5832. (eye)
  5833.     Do not call OpenPoly while another polygon is already
  5834.     open.
  5835. \ ClosePoly
  5836. 2
  5837. Procedure ClosePoly;
  5838.  
  5839.     ClosePoly tells QuickDraw to stop saving the definition of the
  5840. currently open polygon and computes the polyBBox rectangle. You should
  5841. perform one and only one ClosePoly for every OpenPoly. ClosePoly calls
  5842. ShowPen, balancing the HidePen call made by OpenPoly.
  5843.  
  5844.     Here's an example of how to open a polygon, define it as a triangle,
  5845. close it, and draw it:
  5846.  
  5847.     triPoly := OpenPoly;    {save handle and begin collecting stuff}
  5848.       MoveTo (3ØØ,1ØØ);     { move to first point and }
  5849.       LineTo(4ØØ,2ØØ);      {      form       }
  5850.       LineTo(2ØØ,2ØØ);      {       the           }
  5851.       LineTo(3ØØ,1ØØ);      {     triangle    }
  5852.     ClosePoly;              {stop collecting stuff}
  5853.     FillPoly(triPoly,gray); {draw it on the screen}
  5854.     KillPoly(triPoly);      {we're all done}
  5855. \ KillPoly
  5856. 2
  5857. Procedure KillPoly (poly: PolyHandle);
  5858.  
  5859.     KillPoly deallocates space for the polygon whose handle is supplied,
  5860. and returns the memory used by the polygon to the free memory pool.
  5861. Use this only after you are completely through with a polygon.
  5862. \ OffsetPoly
  5863. 2
  5864. Procedure OffsetPoly (poly: PolyHandle; dh,dv: INTEGER);
  5865.  
  5866.     OffsetPoly moves the polygon on the coordinate plane, a distance of
  5867. dh horizontally and dv vertically. This does not affect the screen
  5868. unless your subsequently call a routine to draw the polygon. If dh and
  5869. dv are positive, the movement is to the right and down; if either is
  5870. negative, the corresponding movement is in the opposite direction. The
  5871. polygon retains its shape and size.
  5872.  
  5873. (hand)
  5874.     OffsetPoly is an especially efficient operation, because
  5875.     the data defining a polygon is stored relative to
  5876.     polyStart and so isn't actually changed by OffsetPoly.
  5877. \ FramePoly
  5878. 2
  5879. Procedure FramePoly (poly: PolyHandle);
  5880.  
  5881.     FramePoly plays back the line-drawing routine calls that define the
  5882. given polygon, using the current grafPort's pen pattern, mode, and
  5883. size. The pen will hang below and to the right of each point on the
  5884. boundary of the polygon; thus, the polygon drawn will extend beyond the
  5885. right and bottom edges of poly^^.polyBBox by the pen width and pen
  5886. height, respectively. All other graphic operations occur strictly
  5887. within the boundary of the polygon, as for other shapes. You can see
  5888. this difference in Figure 23, where each of the polygons is shown with
  5889. its polyBBox.
  5890.  
  5891.     If a polygon is open and being formed, FramePoly affects the outline
  5892. of the polygon just as if the line-drawing routines themselves had been
  5893. called. If a region is open and being formed, the outside outline of
  5894. the polygon being framed is mathematically added to the region's
  5895. boundary.
  5896. \ PaintPoly
  5897. 2
  5898. Procedure PaintPoly (poly: PolyHandle);
  5899.  
  5900.     PaintPoly paints the specified polygon with the current grafPort's
  5901. pen pattern and pen mode. The polygon on the bitMap is filled with the
  5902. pnPat, according to the pattern transfer mode specified by pnMode. The
  5903. pen location is not changed by this procedure.
  5904. \ ErasePoly
  5905. 2
  5906. Procedure ErasePoly (poly: PolyHandle);
  5907.  
  5908.     ErasePoly paints the specified polygon with the current grafPort's
  5909. background pattern bkPat (in patCopy mode). The pnPat and pnMode are
  5910. ignored; the pen location is not changed.
  5911. \ InvertPoly
  5912. 2
  5913. Procedure InvertPoly (poly: PolyHandle);
  5914.  
  5915.     InvertPoly inverts the pixels enclosed by the specified polygon:
  5916. every white pixel becomes black and every black pixel becomes white. The
  5917. grafPort's pnPat, pnMode, and bkPat are all ignored; the pen location
  5918. is not changed.
  5919. \ FillPoly
  5920. 2
  5921. Procedure FillPoly (poly: PolyHandle; pat: Pattern);
  5922.  
  5923.     FillPoly fills the specified polygon with the given pattern (in
  5924. patCopy mode.)  The grafPort's pnPat, pnMode, and bkPat are all ignored;
  5925. the pen location is not changed.
  5926. \ AddPt
  5927. 2
  5928. Procedure AddPt (srcPt: Point; VAR dstPt: Point);
  5929.  
  5930.     AddPt adds the coordinates of srcPt to the coordinates of dstPt, and
  5931. returns the result in dstPt.
  5932. \ SubPt
  5933. 2
  5934. Procedure SubPt (srcPt: Point; VAR dstPt: Point);
  5935.  
  5936.     SubPt subtracts the coordinates of srcPt from the coordinates of
  5937. dstPt, and returns the result in dstPt.
  5938. \ SetPt
  5939. 2
  5940. Procedure SetPt (VAR pt: Point; h,v: INTEGER);
  5941.  
  5942.     SetPt assigns two integer coordinates to a variable of type Point.
  5943. \ EqualPt
  5944. 2
  5945. Function EqualPt (ptA,ptB: Point) : BOOLEAN;
  5946.  
  5947.     EqualPt compares the two points and returns true if they are equal
  5948. or FALSE if not.
  5949. \ LocalToGlobal
  5950. 2
  5951. Procedure LocalToGlobal (VAR pt: Point);
  5952.  
  5953.     LocalToGlobal converts the given point from the current grafPort's
  5954. local coordinate system into a global coordinate system with the origin
  5955. (Ø,Ø) at the top left corner of the port's bit image (such as the
  5956. screen). This global point can then be compared to other global
  5957. points, or be changed into the local coordinates of another grafPort.
  5958.  
  5959.     Since a rectangle is defined by two points, you can convert a
  5960. rectangle into global coordinates by performing two LocalToGlobal calls,
  5961. You can also convert a rectangle, region, or polygon into global
  5962. coordinates by calling OffsetRect, OffsetRgn, or OffsetPoly. For
  5963. examples, see GlobalToLocal below.
  5964. \ GlobalToLocal
  5965. 2
  5966. Procedure GlobalToLocal (VAR pt: Point);
  5967.  
  5968.     GlobalToLocal takes a point expressed in global coordinates (with
  5969. the top left corner of the bitMap as coordinate (Ø,Ø)) and converts it
  5970. into the local coordinates of the current grafPort. The global point
  5971. can be obtained with the LocalToGlobal call (see above). For example,
  5972. suppose a game draws a "ball" within a rectangle named ballRect, defined
  5973. in the grafPort named gamePort (as illustrated below in Figure 24). If
  5974. you want to draw that ball in the grafPort named selectPort, you can
  5975. calculate the ball's selectPort coordinates like this:
  5976.  
  5977.     SetPort(gamePort);                  {start in origin port}
  5978.     selectBall:= ballRect;              {make a copy to be moved}
  5979.     LocalToGlobal(selectBall.topLeft);  {put both corners into }
  5980.     LocalToGlobal(selectBall.botRight); {  global coordinates  }
  5981.  
  5982.     SetPort(selectPort);                {switch to destination port}
  5983.     GlobalToLocal(selectBall.topLeft);  {put both corners into     }
  5984.     GlobalToLocal(selectBall.botRight); {  these local coordinates }
  5985.     FillOval(selectBall,ballColor);     {now you have the ball!}
  5986.  
  5987.     You can see from Figure 24 that LocalToGlobal and GlobalToLocal
  5988. simply offset the coordinates of the rectangle by the coordinates of the
  5989. top left corner of the local grafPort's boundary rectangle. You could
  5990. also do this with OffsetRect. In fact the way to convert regions and
  5991. polygons from one coordinate system to another is with OffsetRgn or
  5992. OffsetPoly rather than LocalToGlobal and GlobalToLocal. For example,
  5993. if myRgn were a region enclosed by a rectangle having the same
  5994. coordinates as ballRect in gamePort, you could convert the region to
  5995. global coordinates with
  5996.  
  5997.     OffsetRgn(myRgn, -2Ø, -4Ø);
  5998.  
  5999. and then convert it to the coordinates of the selectPort grafPort with
  6000.  
  6001.     OffsetRgn(myRgn, l5, -3Ø);
  6002. \ Random
  6003. 2
  6004. Function Random : INTEGR;
  6005.  
  6006.     This function returns an integer, uniformly distributedpseudo-
  6007. random, in the range from -32768 through 32767. The value returned
  6008. depends on the global variable randSeed, which InitGraf initializes to
  6009. 1; you can start the sequence over again from where it began by
  6010. resetting randSeed to 1.
  6011. \ GetPixel
  6012. 2
  6013. Function GetPixel (h,v: INTEGER) : BOOLEAN;
  6014.  
  6015.     GetPixel looks at the pixel associated with the given coordinate
  6016. point and returns TRUE if it is black or FALSE if it is white. The
  6017. selected pixel is immediately below and to the right of the point whose
  6018. coordinates are given in h and v, in the local coordinates of the
  6019. current grafPort. There is no guarantee that the specified pixel
  6020. actually belongs to the port, however; it may have been drawn by a port
  6021. overlapping the current one. To see if the point indeed belongs to the
  6022. current port, perform a PtInRgn(pt,thePort^.visRgn).
  6023. \ StuffHex
  6024. 2
  6025. Procedure StuffHex (thingPtr: QDPtr; s: Str255);
  6026.  
  6027.     StuffHex pokes bits (expressed as a string of hexadecimal digits)
  6028. into any data structure. This is a good way to create cursors, patterns,
  6029. or bit images to be "stamped" onto the screen with CopyBits. For
  6030. example,
  6031.  
  6032.     StuffHex(@stripes,'Ø1Ø2Ø4Ø81Ø2Ø4Ø8Ø')
  6033.  
  6034. places a striped pattern into the pattern variable stripes.
  6035.  
  6036. (eye)
  6037.     There is no range checking on the size of the destination
  6038.     variable. It's easy to overrun the variable and destroy
  6039.     something if you don't know what you're doing.
  6040. \ ScalePt
  6041. 2
  6042. Procedure ScalePt (VAR pt: Point; srcRect,dstRect: Rect);
  6043.  
  6044.     A width and height are passed in pt; the horizontal component of pt
  6045. is the width, and the vertical component of pt is the height. ScalePt
  6046. scales these measurements as follows and returns the result in pt: it
  6047. multiplies the given width by the ratio of dstRect's width to srcRect's
  6048. width, and multiplies the given height by the ratio of dstRec's height
  6049. to srcRect's height. In Figure 25, where dstRect's width is twice
  6050. srcRect's width and its height is three times srcRect's height, the pen
  6051. width is scaled from 3 to 6 and the pen height is scaled from 2 to 6.
  6052. \ MapPt
  6053. 2
  6054. Procedure MapPt (VAR pt: Point; srcRect,dstRect: Rect);
  6055.  
  6056.     Given a point within srcRect, MapPt maps it to a similarly located
  6057. point within dstRect (that is, to where it would fall if it were part
  6058. of a drawing being expanded or shrunk to fit dstRect). The result is
  6059. returned in pt. A corner point of srcRect would be mapped to the
  6060. corresponding corner point of dstRect, and the center of srcRect to the
  6061. center of dstRect. In Figure 25 above, the point (3.2) in srcRect is
  6062. mapped to (l8,7) in dstRect. FromRect and dstRect may overlap, and pt
  6063. need not actually be within srcRect.
  6064.  
  6065. (eye)
  6066.     Remember, if you are going to draw inside the rectangle
  6067.     in dstRect, you will probably also want to scale the pen
  6068.     size accordingly with ScalePt.
  6069. \ MapRect
  6070. 2
  6071. Procedure MapRect (VAR r: Rect; srcRect,dstRect: Rect);
  6072.  
  6073.     Given a rectangle within srcRect, MapRect maps it to a similarly
  6074. located rectangle within dstRect by calling MapPt to map the top left
  6075. and bottom right corners of the rectangle. The result is returned in
  6076. r.
  6077. \ MapRgn
  6078. 2
  6079. Procedure MapRgn (rgn: RgnHandle; srcRect: Rect);
  6080.  
  6081.     Given a region within srcRec, MapRgn maps it to a similarly located
  6082. region within dstRect by calling MapPt to map all the points in the
  6083. region.
  6084. \ MapPoly
  6085. 2
  6086. Procedure MapPoly (poly: PolyHandle; srcRect,dstRect: Rect);
  6087.  
  6088.     Given a polygon within srcRect, MapPoly maps it to a similarly
  6089. located polygon within dstRect by calling MapPt to map all the points that
  6090. define the polygon.
  6091. \ SetStdProcs
  6092. 2
  6093. Procedure SetStdProcs (VAR procs: QDProcs);
  6094.  
  6095.     This procedure sets all the fields of the given QDProcs record to
  6096. point to the standard low-level routines. You can then change the ones
  6097. you wish to point to your own routines. For example, if your procedure
  6098. that processes picture comments is named MyComments, you will store
  6099. @MyComments in the commentProc field of the QD Procs record.
  6100.  
  6101.     The routines you install must of course have the same calling
  6102. sequences as the standard routines, which are described below. The
  6103. standard drawing routines tell which graphic operation to perform from a
  6104. parameter of type GrafVerb.
  6105.  
  6106.     TYPE GrafVerb = (frame, paint, erase, invert, fill);
  6107.  
  6108.     When the grafVerb is fill, the pattern to use when filling is passed
  6109. in the fillPat field of the grafPort.
  6110. \ StdText
  6111. 2
  6112. Procedure StdText (byteCount: INTEGER; textBuf: QDPtr; numer,denom:
  6113.         Point);
  6114.  
  6115.     StdText is the standard low-level routine for drawing text. It draws
  6116. text from the arbitrary structure in memory specified by textBuf,
  6117. starting from the first byte and continuing for byteCount bytes. Numer
  6118. and denom specify the scaling, if any:  numer.v over denom.v gives the
  6119. vertical scaling, and numer.h over denom.h gives the horizontal
  6120. scaling.
  6121. \ StdLine
  6122. 2
  6123. Procedure StdLine (newPt: Point);
  6124.  
  6125.     StdLine is the standard low-level routine for drawing a line. It
  6126. draws a line from the current pen location to the location specified (in
  6127. local coordinates) by newPt.
  6128. \ StdRect
  6129. 2
  6130. Procedure StdRect (verb; r: Rect);
  6131.  
  6132.     StdRect is the standard low-level routine for drawing a rectangle.
  6133. It draws the given rectangle according to the specified grafVerb.
  6134. \ StdRRect
  6135. 2
  6136. Procedure StdRRect (verb: GrafVerb; r: Rect; ovalwidth,ovalHeight:
  6137.                     INTEGER);
  6138.  
  6139.     StdRrect is the standard low-level routine for drawing a rounded-
  6140. corner rectangle. It draws the given rounded-corner rectangle according
  6141. to the specified grafVerb. OvalWidth and ovalHeight specify the
  6142. diameters of curvature for the corners.
  6143. \ StdOval
  6144. 2
  6145. Procedure StdOval (verb: GrafVerb; r: Rect);
  6146.  
  6147.     StdOval is the standard low-level routine for drawing an oval. It
  6148. draws an oval inside the given rectangle according to the specified
  6149. grafVerb.
  6150. \ StdArc
  6151. 2
  6152. Procedure StdArc (verb: GrafVerb; r: Rect; startAngle,arcAngle:
  6153.                     INTEGER);
  6154.  
  6155.     StdArc is the standard low-level routine for drawing an arc or a
  6156. wedge. It draws an arc or wedge of the oval that fits inside the given
  6157. rectangle. The grafVerb specifies the graphic operation; it it's the
  6158. frame operation, an arc is drawn; otherwise, a wedge is drawn.
  6159. \ StdPoly
  6160. 2
  6161. Procedure StdPoly (verb: GrafVerb; poly: PolyHandle);
  6162.  
  6163.     StdPoly is the standard low-level routine for drawing a polygon. It
  6164. draws the given polygon according to the specified grafVerb.
  6165. \ StdRgn
  6166. 2
  6167. Procedure StdRgn (verb: GrafVerb; rgn: RgnHandle);
  6168.  
  6169.     StdRgn is the standard low-level routine for drawing a region. It
  6170. draws the given region according to the specified grafVerb.
  6171. \ StdBits
  6172. 2
  6173. Procedure StdBits (VAR srcBits: BitMap; VAR srcRect,dstRect: Rect;
  6174.                     mode: INTEGER; maskRgn: RgnHandle);
  6175.  
  6176.     StdBits is the standard low-level routine for doing bit transfer.It
  6177. transfers a bit image between the given bitMap and thePort^.portBits,
  6178. just as if CopyBits were called with the same parameters and with a
  6179. destination bitMap equal to thePort^.portBits.
  6180. \ StdComment
  6181. 2
  6182. Procedure StdComment (kind,dataSize: INTEGER; dataHandle: QDHandle);
  6183.  
  6184.     StdComment is the standard low-level routine for processing a
  6185. picture comment. Kind identifies the type of comment. DataHandle is a
  6186. handle to additional data, and dataSize is the size of that data in
  6187. bytes. If there is no additional data for the command, dataHandle will
  6188. be NIL and dataSize will be Ø. StdComment simply ignores the comment.
  6189. \ StdTxMeas
  6190. 2
  6191. Function StdTxMeas (byteCount: INTEGER; textBuf: QDPtr; VAR
  6192.                     numer,denom: Point; VAR info: FontInfo) : INTEGER;
  6193.  
  6194.     StdTxMeas is the standard low-level routine for measung text width.
  6195. It returns the width of the text stored in the arbitrary structure in
  6196. memory specified by textBuf, starting with the first byte and
  6197. continuing for byteCount bytes. Numer and denom specify the scaling as
  6198. in the StdText procedure; note that StdTxMeas may change them.
  6199. \ StdGetPic
  6200. 2
  6201. Procedure StdGetPic (dataPtr: QDPtr; byteCount: INTEGER);
  6202.  
  6203.     StdGetPic is the standard low-level routine for retrieving
  6204. information from the definition of a picture. It retrieves the next
  6205. byteCount bytes from the definition of the currently open picture and
  6206. stores them in the data structure pointed to by dataPtr.
  6207. \ StdPutPic
  6208. 2
  6209. Procedure StdPutPic (dataPtr: QdPtr; byteCount: INTEGER);
  6210.  
  6211.     StdPutPic is the standard low-level routine for saving information
  6212. as the definition of a picture. It saves as the definition of the
  6213. currently open picture the drawing commands stored in the data
  6214. structure pointed to by dataPtr, starting with the first byte and
  6215. continuing for the next byteCount bytes.
  6216. \ SeedFill
  6217. 2
  6218. Procedure SeedFill (srcPtr,dstPtr: Ptr; srcRow, dstRow, height,
  6219.                     words,seedH,seedV: INTEGER);
  6220.  
  6221.     Given a source bit image, SeedFill computes a destination bit image
  6222. with 1’s only in the pixels where paint can leak from the starting
  6223. seed point, like the MacPaint paint-bucket tool. SeedH and seedV
  6224. specify horizontal and vertical offsets, in pixels, from the beginning
  6225. of the data pointed to by dstPtr, determining how far into the
  6226. destination bit image filling should begin. Calls to SeedFill are not
  6227. clipped to the current port and are not stored into QuickDraw pictures.
  6228. \ CalcMask
  6229. 2
  6230. Procedure CalcMask (srcPtr,dstPtr: Ptr; srcRow, dstRow, height,
  6231.                     words: INTEGER);
  6232.  
  6233.     Given a source bit image, CalcMask computes a destination bit image
  6234. with 1’s only in the pixels where paint could not leak from any of
  6235. the outer edges, like the MacPaint lasso tool. Calls to CalcMask are
  6236. not clipped to the current port and are not stored into QuickDraw
  6237. pictures.
  6238. \ MeasureText
  6239. 2
  6240. Procedure MeasureText (count: INTEGER; textAddr,charLocs: Ptr);
  6241.  
  6242.     This procedure is designed to improve performance in specialized
  6243. applications such as word processors by providing an array version of
  6244. the TextWidth function; it’s like calling TextWidth repeatedly for a
  6245. given set of characters. TextAddr points to an arbitrary piece of text
  6246. in memory, and count specifies how many characters are to be measured.
  6247.  
  6248.     MeasureText moves along the string and, for each character, computes
  6249. the distance from TextAddr to the right edge of the character.
  6250. CharLocs should point to an array of count + 1 integers. Upon return,
  6251. the first element in the array will always contain 0; the other elements
  6252. will contain pixel positions on the screen for all of the specified
  6253. characters.
  6254.  
  6255. Note:   MeasureText only works with text displayed on the screen;
  6256.         since it doesn’t go through the QuickDraw procedure StdText, it
  6257.         can’t be used to measure text to be printed.
  6258.  
  6259. \ GetMaskTable
  6260. 2
  6261.     The function GetMaskTable, accessible only from assembly language,
  6262. returns in register A0 a pointer to a ROM table containing the following
  6263. useful masks:
  6264.  
  6265. .WORD $0000,$8000,$C000,$E000   ;Table of 16 right masks
  6266. .WORD $F000,$F800,$FC00,$FE00
  6267. .WORD $FF00,$FF80,$FFC0,$FFE0
  6268. .WORD $FFF0,$FFF8,$FFFC,$FFFE
  6269.  
  6270. .WORD $FFFF,$7FFF,$3FFF,$1FFF   ;Table of 16 left masks
  6271. .WORD $0FFF,$07FF,$03FF,$01FF
  6272. .WORD $00FF,$007F,$003F,$001F
  6273. .WORD $000F,$0007,$0003,$0001
  6274.  
  6275. .WORD $8000,$4000,$2000,$1000   ;Table of 16 bit masks
  6276. .WORD $0800,$0400,$0200,$0100
  6277. .WORD $0080,$0040,$0020,$0010
  6278. .WORD $0008,$0004,$0002,$0001
  6279.  
  6280. _GetMaskTable : Macro Name.
  6281. \ InitFonts
  6282. 3
  6283. Procedure InitFonts;
  6284.  
  6285.     InitFonts initializes the Font Manager. If the system font isn't
  6286. already in memory, InitFonts reads it into memory. Call this procedure
  6287. once before all other Font Manager routines or any Toolbox routine that
  6288. will call the Font Manager.
  6289. \ GetFontName
  6290. 3
  6291. Procedure GetFontName (fontNum: INTEGER; VAR theName: Str255);
  6292.  
  6293.     GetFontName returns in theName the name of the font having the font
  6294. number fontNum. If there's no such font, GetFontName returns the empty
  6295. string.
  6296. \ GetFNum
  6297. 3
  6298. Procedure GetFNum (fontName: Str255; VAR theNum: INTEGER);
  6299.  
  6300.     GetFNum returns in theNum the font number for the font having the
  6301. given fontName. If there's no such fone getFNum returns Ø.
  6302. \ RealFont
  6303. 3
  6304. Function RealFont (fontNum: INTEGER; size: INTEGER) : BOOLEAN;
  6305.  
  6306.     RealFont returns TRUE if the font having the font number fontNum is
  6307. available in the given size in a resource file, or FALSE if the font
  6308. has to be scaled to that size.
  6309. \ SetFontLock
  6310. 3
  6311. Procedure SetFontLock (lockFlag: BOOLEAN);
  6312.  
  6313.     SetFontLock applies to the font in which text was most recently
  6314. drawn; it makes the font unpurgeable if lockFlag is TRUE or purgeable if
  6315. lockFlag is FALSE. Since fonts are normally purgeable, this procedure
  6316. is useful for making a font temporarily unpurgeable.
  6317. \ SwapFont
  6318. 3
  6319. Function SwapFont (inRec: FMInput) : FMOutPtr;
  6320.  
  6321.     SwapFont returns a pointer to an FMOutput record containing the
  6322. size, style, and other information about an adapted version of the font
  6323. requested in the given FMInput record. (FMInput and FMOutput records
  6324. are explained in the following section.)  SwapFont is called by
  6325. QuickDraw every time a QuickDraw routine that does anything with text
  6326. is used. If you want to call SwapFont yourself, you must build an
  6327. FMInput record and then use the returned pointer to access the
  6328. resulting FMOutput record.
  6329. \ FontMetrics
  6330. 3
  6331. Procedure FontMetrics (VAR theMetrics: FMetricRec);
  6332.  
  6333.     FontMetrics is similar to the QuickDraw procedure GetFontInfo except
  6334. that it returns fixed-point values for greater accuracy in
  6335. high-resolution printing.
  6336.  
  6337. The FMetricRec data structure is defined as follows:
  6338.  
  6339. TYPE FMetricRec = RECORD
  6340.          ascent:    Fixed;  {ascent}
  6341.          descent:   Fixed;  {descent}
  6342.          leading:   Fixed;  {leading}
  6343.          widMax:    Fixed;  {maximum character width}
  6344.          wTabHandle:    Handle; {handle to global width table}
  6345.        END;
  6346.  
  6347.     Ascent, descent, leading, and widMax are identical in function to
  6348. their counterparts in GetFontInfo. WTabHandle is a handle to the
  6349. global width table (described below).
  6350.  
  6351. \ SetFractEnable
  6352. 3
  6353. Procedure SetFractEnable (fractEnable: BOOLEAN)
  6354.  
  6355.     SetFractEnable lets you enable or disable fractional character
  6356. widths. If fractEnable is TRUE, fractional character widths are enabled;
  6357. if it’s FALSE, the Font Manager uses integer widths. To ensure
  6358. compatibility with existing applications, fractional character widths
  6359. are disabled by default.
  6360. ___________________________________________________________________
  6361.  
  6362. Assembly-language note:  From assembly language, you can change the
  6363. value of the global variable FractEnable.
  6364. ___________________________________________________________________
  6365. \ SetFScaleDisable
  6366. 3
  6367. Procedure SetFScaleDisable (fontScaleDisable: BOOLEAN);
  6368.  
  6369.     SetFScaleDisable lets you disable or enable font scaling.
  6370. If fontScaleDisable is TRUE, font scaling is disabled and
  6371. the Font Manager returns an unscaled font with more space around
  6372. the characters; if it’s FALSE, the Font Manager scales fonts.
  6373. To ensure compatibility with existing applications, the Font Manager
  6374. defaults to scaling fonts.
  6375.  
  6376.     ______________________________________________________________
  6377.     Assembly-language note:  All programmers should use the
  6378.     SetFScaleDisable procedure to disable and enable font scaling.
  6379.     In particular, setting the global variable FScaleDisable is
  6380.     insufficient.
  6381.     ______________________________________________________________
  6382. \ GetNextEvent
  6383. 4
  6384. Function GetNextEvent (eventMask: INTEGER; VAR theEvent: EventRecord)
  6385.                         : BOOLEAN;
  6386.  
  6387.     GetNextEvent returns the next available event of a specified type or
  6388. types and, if the event is in the event queue, removes it from the
  6389. queue. The event is returned as the value of the parameter theEvent.
  6390. The eventMask parameter specifies which event types are of interest.
  6391. GetNextEvent returns the next available event of any type designated by
  6392. the mask, subject to the priority rules discussed above under "Priority
  6393. of Events". If no event of any of the designated types is available,
  6394. GetNextEvent returns a null event.
  6395.  
  6396. (note)
  6397.     Events in the queue that aren't designated in the mask
  6398.     are kept in the queue; if you want to remove them, you
  6399.     can do so by calling the Operating System Event Manager
  6400.     procedure FlushEvents.
  6401.  
  6402.     Before reporting an event to your application, GetNextEvent first
  6403. calls the Desk Manager function System Event to see whether the system
  6404. wants to intercept and respond to the event. If so, or if the event
  6405. being reported is a null event, GetNextEvent returns a function result
  6406. of FALSE; a function result of TRUE means that your application should
  6407. handle the event itself. The Desk Manager intercepts the following
  6408. events:
  6409.  
  6410.     - activate and update events directed to a desk accessory
  6411.  
  6412.     - keyboard events if the currently active window belongs to a desk
  6413.       accessory
  6414.  
  6415. (note)
  6416.     In each case, the event is intercepted by the Desk
  6417.     Manager only if the desk accessory can handle that type
  6418.     of event; however, as a rule all desk accessories should
  6419.     be set up to handle activate, update, and keyboard
  6420.     events.
  6421.  
  6422.     The Desk Manager also intercepts disk-inserted events:  It attempts
  6423. to mount the volume on the disk by calling the File Manager function
  6424. MountVol. GetNextEvent will always return TRUE in this case, though,
  6425. so that your application can take any further appropriate action after
  6426. examining the result code returned by MountVol in the event message.
  6427. (See the Desk Manager and File Manager manuals for further details.)
  6428. GetNextEvent returns TRUE for all other non-null events (including all
  6429. mouse-down events, regardless of which window is active), leaving them
  6430. for your application to handle.
  6431.  
  6432.     GetNextEvent also makes the following processing happen, invisible
  6433. to your program:
  6434.  
  6435.    -If the "alarm" is set and the current time is the alarm time, the
  6436.     alarm goes off (a beep followed by blinking the title of the Apple
  6437.     menu). The user can set the alarm with the Alarm Clock desk
  6438.     accessory.
  6439.  
  6440.    -If the user holds down the Command and Shift keys while pressing a
  6441.     numeric key that has a special effect, that effect occurs. The
  6442.     standard such keys are 1 and 2 for ejecting the disk in the
  6443.     internal or external drive, and 3 and 4 for writing a snapshot of
  6444.     the screen to a MacPaint document or to the printer.
  6445.  
  6446.  (note)
  6447.     Advanced programmers can implement their own code to be
  6448.     executed in response to Command-Shift-number combinations
  6449.     (except for Command-Shift-l and 2, which can't be
  6450.     changed). The code corresponding to a particular number
  6451.     must be a routine having no parameters, stored in a
  6452.     resource whose type is 'FKEY' and whose ID is the number.
  6453.     The system resource file contains code for the numbers 3
  6454.     and 4.
  6455. \ EventAvail
  6456. 4
  6457. Function EventAvail (eventMask: INTEGER; VAR theEvent: EventRecord) :
  6458.     BOOLEAN;
  6459.  
  6460.     EventAvail works exactly the same as GetNextEvent except that if the
  6461. event is in the event queue, it's left there.
  6462.  
  6463. (note)
  6464.     An event returned by EventAvail will not be accessible
  6465.     later if in the meantime the queue becomes full and the
  6466.     event is discarded from it; since the events discarded
  6467.     are always the oldest ones in the queue, however, this
  6468.     will happen only in an unusually busy environment.
  6469. \ GetMouse
  6470. 4
  6471. Procedure GetMouse (VAR mouseLoc: Point);
  6472.  
  6473.     GetMouse returns the current mouse location in the mouseLoc
  6474. parameter. The location is given in the local coordinate system of the
  6475. current grafPort (which might be, for example, the currently active
  6476. window). Notice that this differs from the mouse location stored in the
  6477. where field of an event record; that location is always in global
  6478. coordinates.
  6479. \ Button
  6480. 4
  6481. Function Button : BOOLEAN;
  6482.  
  6483.     The Button function returns TRUE if the mouse button is currently
  6484. down, and FALSE if it isn't.
  6485. \ Stilldown
  6486. 4
  6487. Function StillDown : BOOLEAN;
  6488.  
  6489.     Usually called after a mouse-down event, StillDown tests whether the
  6490. mouse button is still down. It returns TRUE if the button is currently
  6491. down and there are no more mouse events pending in the event queue.
  6492. This is a true test of whether the button is still down from the
  6493. original press--unlike Button (above), which returns TRUE whenever the
  6494. button is currently down, even it ift has been released and pressed
  6495. again since the original mouse-down event.
  6496. \ WaitMouseUp
  6497. 4
  6498. Function WaitMouseUp: BOOLEAN;
  6499.  
  6500.     WaitMouseUp works exactly the same as StillDown (above), excent that
  6501. if the button is not still down from the original press, WaitMouseUp
  6502. removes the preceding mouse-up event before returning FALSE. If, for
  6503. instance, your application attaches some special significance both to
  6504. mouse double-clicks and to mouse-up events, this function would allow
  6505. your application to recognize a double-click without being confused by
  6506. the intervening mouse-up.
  6507. \ GetKeys
  6508. 4
  6509. Procedure GetKeys (VAR theKeys: KeyMap);
  6510.  
  6511.     GetKeys reads the current state of the keyboard (and keypad, if any)
  6512. and returns it in the form of a keyMap:
  6513.  
  6514.     TYPE KeyMap = PACKED ARRAY [Ø..127] OF BOOLEAN;
  6515.  
  6516.     Each key on the keyboard or keypad corresponds to an element in the
  6517. keyMap. The index into the keyMap for a particular key is the same as
  6518. the key code for that key. (The key codes are shown in Figure 3
  6519. above.)  The keyMap element is TRUE if the corresponding key is down
  6520. and FALSE if it isn't. The maximum number of keys that can be down
  6521. simultaneously is two character keys plus any combination of the four
  6522. modifier keys.
  6523. \ TickCount
  6524. 4
  6525. Function TickCount : LONGINT;
  6526.  
  6527.     TickCount returns the current number of ticks (sixtieths of a
  6528. second) since the system was last started up.
  6529. \ GetDblTime
  6530. 4
  6531. Function GetDblTime : LONGINT; [No trap macro]
  6532.  
  6533.     GetDblTime returns the suggested maximum difference (in ticks) that
  6534. should exist between the times of a mouse-up event and a mouse-down
  6535. event for those two mouse clicks to be considered a double-click. The
  6536. user can adjust this value by means of the Control Panel desk
  6537. accessory.
  6538. \ GetCaretTime
  6539. 4
  6540. Function GetCaretTime : LONGINT; [No trap macro]
  6541.  
  6542.     GetCareTime returns the time (in ticks) between blinks of the
  6543. "caret" (usually a vertical bar) marking an insertion point in editable
  6544. text. If you aren't using TextEdit, you'll need to cause the caret to
  6545. blink yourself; on every pass through your program's main event loop,
  6546. you should check this value against the elapsed time since the last
  6547. blink of the caret. The user can adjust this value by means of the
  6548. Control Panel desk accessory.
  6549. \ InitWindows
  6550. 5
  6551. Procedure InitWindows;
  6552.  
  6553.     InitWindows initializes the Window Manager. It creates the Window
  6554. Manager port; you can get a pointer to this port with the GetWMgrPort
  6555. Procedure. InitWindows draws the desktop and the (empty menu bar.
  6556. Call this procedure once berore all other Window Manager routines.
  6557.  
  6558. (note)
  6559.     InitWindows creates the Window Manager port as a
  6560.     nonrelocatable block in the application heap. For
  6561.     information on how this may affect your application's use
  6562.     of memory, see the Memory Manager manual. ***(A section
  6563.     on how to survive with limited memory will be added to
  6564.     that manual.) ***
  6565. \ GetWMgrPort
  6566. 5
  6567. Procedure GetWMgrPort (VAR wPort:  GrafPtr);
  6568.  
  6569.     GetWMgrPort returns in wPort a pointer to the Window Manager port.
  6570. \ NewWindow
  6571. 5
  6572. Function NewWindow (wStorage: Ptr; boundsRect: Rect; title: Str255;
  6573.                     visible: BOOLEAN; procID: Integer;behind: WindowPtr;
  6574.                     goAway Flag: BOOLEAN; refCon: LongInt) : WindowPtr;
  6575.  
  6576.     NewWindow creates a window as specified by its parameters, adds it
  6577. to the window list, and returns a windowPtr to the new window. It
  6578. allocates space for the structure and content regions of the window and
  6579. asks the window definition function to calculate those regions.
  6580.  
  6581.     WStorage is a pointer to where to store the window record. For
  6582. example, if you've declared the variable wRecord of type WindowRecord,
  6583. you can pass @wRecord as the first parameter to NewWindow. If you pass
  6584. NIL for wStorage, the window record will be allocated on the heap; in
  6585. that case, though, the record will be nonrelocatable, and so you risk
  6586. ending up with a fragmented heap. You should therefore not pass NIL
  6587. for wStorage unless your program has an unusually large amount of
  6588. memory available or has been set up to dispose of windows dynamically.
  6589. Even then, you should avoid passing NIL for wStorage if there's no
  6590. limit to the number of windows that your application can open. ***
  6591. (Some of this may be moved to the Memory Manager manual when that
  6592. manual is updated to have a section on how to survive with limited
  6593. memory.) ***
  6594.  
  6595.     BoundsRect, a rectangle given in global coordinates, determines the
  6596. window's size and location. It becomes the portRect of the window's
  6597. grafPort; note, however, that the portRect is in local coordinates.
  6598. New Window makes the QuickDraw call SetOrigin(Ø,Ø), so that the top left
  6599. corner of the portRect will be (Ø,Ø).
  6600.  
  6601. (note)
  6602.     The bitMap, pen pattern, and other characteristics of the
  6603.     window's grafPort are the same as the default values set
  6604.     by the OpenPort procedure in QuickDraw, except for the
  6605.     character font, which is set to the application font
  6606.     rather than the system font. Note, however, that the
  6607.     SetOrigin(Ø,Ø) call changes the coordinates of the
  6608.     grafPort's portBits.bounds and visRgn as well as its
  6609.     PortRect.
  6610.  
  6611.     Title is the window's title. If the title of a document window is
  6612. longer than will fit in the title bar, only as much of the beginning of
  6613. the title as will fit is displayed.
  6614.  
  6615.     If the visible parameter is TRUE, NewWindow draws the window. First
  6616. it calls the window definition function to draw the window frame; if
  6617. goAwayFlag is also TRUE and the window is frontmost (as specified by
  6618. the behind parameter, below), it draws a go-away region in the frame.
  6619. Then it generates an update event for the entire window contents.
  6620.  
  6621.     ProcID is the window definition ID, which leads to the window
  6622. definition function for this type of window. The window definition IDs
  6623. for the predefined types of windows are listed above under "Windows and
  6624. Resources". Window definition IDs for windows of your own design are
  6625. discussed later under "Defining Your Own Windows".
  6626.  
  6627.     The behind parameter determines the window's plane. The new window
  6628. is inserted in back of the window pointed to by this parameter. To put
  6629. the new window behind all other windows, use behind=NIL. To place it
  6630. in front of all other windows, use behind=POINTER(-1); in this case,
  6631. NewWindow will unhighlight the previously active window, highlight the
  6632. window being created, and generate appropriate activate events.
  6633.  
  6634.     RefCon is the window's reference value, set and used only by your
  6635. application.
  6636.  
  6637.     NewWindow also sets the window class in the window record to
  6638. indicate that the window was created directly by the application.
  6639. \ GetNewWindow
  6640. 5
  6641. Function GetNewWindow (ID: INTEGER; wStorage: Ptr; behind:
  6642.                         WindowPtr) : WindowPtr;
  6643.  
  6644.     Like NewWindow (above), GetNewWindow creates a window as specified
  6645. by its parameters, adds it to the window list, and returns a windowPtr
  6646. to the new window. The only difference between the two functions is
  6647. that instead of having the parameters boundsRect, title, visible,
  6648. procId, goAwayFlag, and refCon, GetNewWindow has a single windowID
  6649. parameter, where windowID is the resource ID of a window template that
  6650. supplies the same information as those parameters. The wStorage and
  6651. behind parameters of GetNewWindow have the same meaning as in NewWindow.
  6652. \ CloseWindow
  6653. 5
  6654. Procedure CloseWindow (theWindow: WindowPtr);
  6655.  
  6656.     CloseWindow removes the given window from the screen and deletes it
  6657. from the window list. It releases the memory occupied by all data
  6658. structures associated with the window, but not the memory taken up by
  6659. the window record itself. Call this procedure when you're done with a
  6660. window if you supplied NewWindow or GetNewWindow a pointer to the
  6661. window storage (in the wStorage parameter) when you created the window.
  6662.  
  6663.     Any update events for the window are discarded. If the window was
  6664. the frontmost window and there was another window behind it, the latter
  6665. window is highlighted and an appropriate activate event is generated.
  6666. \ DisposeWindow
  6667. 5
  6668. Procedure DisposeWindow (theWindow: WindowPtr);
  6669.  
  6670.     DisposeWindow calls CloseWindow (above) and then releases the memory
  6671. occupied by the window record. Call this procedure when you're done
  6672. with a window if you let the window record be allocated on the heap
  6673. when you created the window (by passing NIL as the wStorage parameter
  6674. to NewWindow or GetNewWindow).
  6675. \ SetWTitle
  6676. 5
  6677. Procedure SetWTitle (theWindow: WindowPtr; title: Str255);
  6678.  
  6679.     SetWTitle sets the Window's title to the given string, performing
  6680. any necessary redrawing of the window frame.
  6681. \ GetWTitle
  6682. 5
  6683. Procedure GetWTitle (theWindow: WindowPtr; VAR title: Str255);
  6684.  
  6685.     GetWTitle returns theWindow's title as the value of the title
  6686. parameter.
  6687. \ SelectWindow
  6688. 5
  6689. Procedure SelectWindow (theWindow: WindowPtr);
  6690.  
  6691.     SelectWindow makes theWindow the active window as follows:  it
  6692. unhighlights the previously active window, brings theWindow in front of
  6693. all other windows, highlights theWindow, and generates the appropriate
  6694. activate events. Call this procedure if there's a mouse-down event in
  6695. the content region of an inactive window.
  6696. \ HideWindow
  6697. 5
  6698. Procedure HideWindow (theWindow: WindowPtr);
  6699.  
  6700.     HideWindow makes theWindow invisible. If theWindow is the frontmost
  6701. window and there's a window behind it, HideWindow also unhighlights
  6702. theWindow, brings the window behind it to the front, highlights that
  6703. window, and generates appropriate activate events (se Figure 6). If
  6704. theWindow is already invisible, HideWindow has no effect.
  6705. \ ShowWindow
  6706. 5
  6707. Procedure ShowWindow (theWindow: WindowPtr);
  6708.  
  6709.     ShowWindow makes theWindow visible. It does not change the front-to-
  6710. back ordering of the windows. Remember that if you previously hid the
  6711. frontmost window with HideWindow, HideWindow will have brought the
  6712. window behind it to the front; so if you then do a ShowWindow of the
  6713. window you hid, it will no longer be frontmost (see Figure 6 above).
  6714. If the Window is already visible, ShowWindow has no effect.
  6715.  
  6716. (note)
  6717.     Although it's inadvisable, you can create a situation
  6718.     where the frontmost window is invisible. If you do a
  6719.     ShowWindow of such a window, it will highlight the window
  6720.     if it's not already highlighted and will generate an
  6721.     activate event to force this window from inactive to
  6722.     active.
  6723. \ ShowHide
  6724. 5
  6725. Procedure ShowHide (theWindow: WindowPtr; showFlag: BOOLEAN);
  6726.  
  6727.     If showFlag is FALSE, ShowHide makes theWindow invisible if it's not
  6728. already invisible and has no effect if it is already invisible. If
  6729. showFlag is TRUE, ShowHide makes the Window visible if it's not already
  6730. visible and has no effect if it is already visible. Unlike HideWindow
  6731. and ShowWindow, ShowHide never changes the highlighting or front-to-
  6732. back ordering of windows or generates activates events.
  6733.  
  6734. (warning)
  6735.     Use this procedure carefully, and only in special
  6736.     circumstances where you need more control than allowed by
  6737.     HideWindow and ShowWindow.
  6738. \ HiliteWindow
  6739. 5
  6740. Procedure HiliteWindow (theWindow: WindowPtr; fHilite: BOOLEAN);
  6741.  
  6742.     If fHilite isTRUE, this procedure highlights theWindow if it's not
  6743. already highlighted and has no effect if it is highlighted. If fHilite
  6744. is FALSE, HiliteWindow unhighlights theWindow if it is highlighted and
  6745. has no effect if it's not highlighted. The exact way a window is
  6746. highlighted depdnds on its window definition function.
  6747.  
  6748.     Normally you won't have to call this procedure, since you should
  6749. call SelectWindow to make a window active, and SelectWindow takes care
  6750. of the necessary highlighting changes. Highlighting a window that isn't
  6751. the active window is contrary to the Macintosh User Interface
  6752. Guidelines.
  6753. \ BringToFront
  6754. 5
  6755. Procedure BringToFront (theWindow: WindowPtr);
  6756.  
  6757.     BringToFront brings theWindow to the front of all other windows and
  6758. redraws the window as necessary. Normally you won't have to call this
  6759. Procedure, since you should call SelectWindow to make a window active,
  6760. and SelectWindow takes care of bringing the window to the front. If
  6761. you do call BringToFront, however, remember to call HiliteWindow to
  6762. make the necessary highlighting changes.
  6763. \ SendBehind
  6764. 5
  6765. Procedure SendBehind (theWindow: WindowPtr; behindWindow: WindowPtr);
  6766.  
  6767.     SendBehind sends theWindow behind behindWindow, redrawing any
  6768. exposed windows. If behindWindow is NIL, it sends theWindow behind all
  6769. other windows. If theWindow is the active window, it unhighlights the
  6770. Window, highlights the new active window, and generates the appropriate
  6771. activate events.
  6772.  
  6773. (warning)
  6774.     Do not use SendBehind to deactivate a previously active
  6775.     window. Calling SelectWindow to make a window active
  6776.     takes care of deactivating the previously active window.
  6777.  
  6778. (note)
  6779.     If you're moving theWindow closer to the front (that is,
  6780.     if it's initially even farther behind behind(Window), you
  6781.     must make the following calls after calling SendBehind:
  6782.  
  6783.         wPeek := POINTER(theWindow);
  6784.         PaintOne(wPeek, wPeek^.strucRgn);
  6785.         CalcVis(wPeek)
  6786.  
  6787.     PaintOne and CalcVis are described below under "Low'Level
  6788.     Routines".
  6789. \ FrontWindow
  6790. 5
  6791. Function FrontWindow : WindowPtr;
  6792.  
  6793.     FrontWindow returns a pointer to the first visible window in the
  6794. window list (that is, the active window). If there are no visible
  6795. windows, it returns NIL.
  6796. \ DrawGrowIcon
  6797. 5
  6798. Procedure DrawGrowIcon (theWindow: WindowPtr).
  6799.  
  6800.     Call DrawGrowIcon in responce to an update or activate event
  6801. involving a window that contains a size box in its content region. If
  6802. theWindow is active (highlighted), DrawGrowIcon draws the size box;
  6803. otherwise, it draws whatever is appropriate to show that thewindow
  6804. temporily cannot be sized. The exact appearance and location of what's
  6805. drawn depend on the window definition function. For an active document
  6806. window, DrawGrowIcon draws the size box icon in the bottom right corner
  6807. of the portRect of the window's grafPort, along with the lines
  6808. delimiting the size box and scroll bar areas (15 pixels in from the
  6809. right edge and bottom of the portRect). It doesn't erase the scroll
  6810. bar areas, so if the window doesn't contain scroll bars you should
  6811. erase those areas yourself after the window's size changes. For an
  6812. inactive document window, DrawGrowIcon draws only the delimiting lines
  6813. (again, without erasing anything).
  6814. \ FindWindow
  6815. 5
  6816. Function FindWindow (thePt: Point; VAR whichWindow: WindowPtr) :
  6817.     INTEGER;
  6818.  
  6819.     When a mouse-down event occurs, the application should call
  6820. FindWindow with thePt equal to the point where the mouse button was
  6821. pressed (in global coordinates, as stored in the where field of the
  6822. event record). FindWindow tells which part of which window, if any, the
  6823. mouse button was pressed in. If it was pressed in a window, the
  6824. whichWindow parameter is set to the window pointer; otherwise, it's set
  6825. to NIL. The integer returned by FindWindow is one of the following
  6826. predefined constants:
  6827.  
  6828. CONST inDesk      = Ø;  {none of the following}
  6829.       InMenuBar   = 1;  {in menu bar}
  6830.       inSysWindow = 2;  {in system window}
  6831.       inContent   = 3;  {in content region (except grow, if active)}
  6832.       inDrag      = 4;  {in drag region}
  6833.       inGrow      = 5;  {in grow region (active window only)}
  6834.       inGoAway    = 6;  {in go-away region (active window only)}
  6835.       inZoomin    = 7;
  6836.       inZoomOut   = 8;
  6837.  
  6838.     InDesk usually means that the mouse button was pressed on the
  6839. desktop, outside the menu bar or any windows; however, it may also mean
  6840. that the mouse button was pressed inside a window frame but not in the
  6841. drag region or go-away region of the window. Usually one of the last
  6842. four values is returned for windows created by the application.
  6843.  
  6844.     If the window is a documentProc type of window that doesn't contain
  6845. a size box, the application should treat  inGrow the same as inContent;
  6846. if it's a noGrowDocProc type of window, FindWindow will never return
  6847. inGrow for that window. If the window is a documentProc, noGrowDocProc,
  6848. or rDocProc type of window with no close box, FindWindow will never
  6849. return inGoAway for that window.
  6850. \ TrackGoAway
  6851. 5
  6852. Function TrackGoAway (theWindow: WindowPtr; thePt: Point) : BOOLEAN;
  6853.  
  6854.     When there's a mouse-down event in the go-away region of theWindow,
  6855. the application should call TrackGoAway with thePt equal to the point
  6856. where the mouse button was pressed (in global coordinates, as stored in
  6857. the where field of the event record). TrackGoAway keeps control until
  6858. the mouse button is released, highlighting the go-away region as long as
  6859. the mouse position remains inside it, and unhighlighting it when the
  6860. mouse moves outside it. The exact way a window's go-away region is
  6861. highlighted depends on its window definition function; the highlighting
  6862. of a document window's close box is illustrated in Figure 7. When the
  6863. mouse  button is released, TrackGoAway unhighlights the go-away region
  6864. and returns TRUE if the mouse is inside the go-away region or FALSE if
  6865. it's outside the region (in which case the application should do
  6866. nothing).
  6867. \ MoveWindow
  6868. 5
  6869. Procedure MoveWindow (theWindow: WindowPtr; hGlobal,vGlobal: INTEGER;
  6870.     front: BOOLEAN);
  6871.  
  6872.     MoveWindow moves theWindow to another part of the screen, without
  6873. affecting its size or plane.  The top left corner of the portRect of
  6874. the window's grafPort is moved to the screen point indicated by the
  6875. global coordinates hGlobal and vGlobal. The local coordinates of the
  6876. top left corner remain the same; MoveWindow saves those coordinates
  6877. before moving the window and calls the QuickDraw procedure SetOrigin to
  6878. restore them before returning. If the front parameter is TRUE and
  6879. theWindow isn't the active window, MoveWindow makes it the active
  6880. window by calling SelectWindow(theWindow).
  6881. \ DragWindow
  6882. 5
  6883. Procedure DragWindow (theWindow: WindowPtr; startPt: Point; boundsRect:
  6884.     Rect);
  6885.  
  6886.     When there's a mouse-down event in the drag region of theWinow, the
  6887. application should call DragWindow with StartPt equal to the point
  6888. where the mouse button was pressed (in global coordinates, as stored in
  6889. the where field of the event record). DragWindow pulls a gray outline
  6890. of theWindow around, following the movements of the mouse until the
  6891. button is released. When the mouse button is released, DragWindow
  6892. calls MoveWindow to move theWindow to the location to which it was
  6893. dragged. If theWindow is not the active window and the Command key was
  6894. not being held down, DragWindow makes it the active window (by passing
  6895. TRUE for the front parameter when calling MoveWindow).
  6896.  
  6897.     BoundsRect is also given in global coordinates. If the mouse button
  6898. is released when the mouse position is outside the limits of boundsRect,
  6899. DragWindow returns without moving theWindow or making it the active
  6900. window. For a document window, boundsRect typically will be four
  6901. pixels in from the menu bar and from the other edges of the screen, to
  6902. ensure that there won't be less than a four-pixel-square area of the
  6903. title bar visible on the screen.
  6904. \ GrowWindow
  6905. 5
  6906. Function GrowWindow (theWindow: WindowPtr; startPt: Point; sizeRect:
  6907.     Rect) : LongInt;
  6908.  
  6909.     When there's a mouse-down event in the grow region of theWindow, the
  6910. application should call GrowWindow with startPt equal to the point
  6911. where the mouse button was pressed (in global ccoordinates, as stored in
  6912. the where field of the event record). GrowWindow pulls a GROW IMAGE of
  6913. the window around, following the movements of the mouse until the
  6914. button is released. The grow image for a document window is a gray
  6915. outline of the entire window and also the lines delimiting the title
  6916. bar, size box, and scroll bar areas; Figure 8 illustrates this for a
  6917. document window containing a size box and scroll bars, but the grow
  6918. image would be the same even if the window contained no size box, one
  6919. scroll bar, or no scroll bars. In general, the grow image is defined
  6920. in the window definition function and is whatever is appropriate to
  6921. show that the window's size will change.
  6922.  
  6923.     The application should subsequently call SizeWindow (see below) to
  6924. change the portRect of the window's grafPort to the new one outlined by
  6925. the grow image. The sizeRect parameter specifies limits, in pixels, on
  6926. the vertical and horizontal measurements of what will be the new
  6927. portRect. SizeRect.top is the minimum vertical measurement,
  6928. sizeRect.left is the minimum horizontal measurement, sizeRect.bottom is
  6929. the maximum vertical measurement, and sizeRect.right is the maximum
  6930. horizontal measurement.
  6931.  
  6932.     GrowWindow returns the actual size for the new portRect as outlined
  6933. by the grow image when the mouse button is released. The high-order
  6934. word of the LongInt is the vertical measurement in pixels and the
  6935. low-order word is the horizontal measurement. A return value of Ø
  6936. indicates that the size is the same as that of the current portRect.
  6937.  
  6938. (note)
  6939.     The Toolbox Utility function HiWord takes a long integer
  6940.     as a parameter and returns an integer equal to its high-
  6941.     order word; the function LoWord returns the low-order
  6942.     word.
  6943. \ SizeWindow
  6944. 5
  6945. Procedure SizeWindow (theWindow: WindowPtr; w,h: INTEGER; fUpdate:
  6946.     BOOLEAN);
  6947.  
  6948.     SizeWindow enlarges or shrinks the portRect of the Window's grafPort
  6949. to the width and height specified by w and h, or does nothing if w and h
  6950. are Ø. The window's position on the screen does not change. The new
  6951. window frame is drawn; if the width of a document window changes, the
  6952. title is again centered in the title bar, or is truncated at its end if
  6953. it no longer fits. If fUpdate is TRUE, SizeWindow accumulates any
  6954. newly created area of the content region into the update region (see
  6955. figure 9);  normally this is what you'll want. If you pass FALSE for
  6956. fUpdate, you're responsible for the update region maintenance yourself.
  6957. For more information, see InvalRect and ValidRect below.
  6958.  
  6959. (note)
  6960.     You should change the window's size only when the user
  6961.     has done something specific to make it change.
  6962. \ InvalRect
  6963. 5
  6964. Procedure InvalRect (badRect: Rect);
  6965.  
  6966.     InvalRect accumulates the given rectangle into the update region of
  6967. the window whose grafPort is the current port. This tells the Window
  6968. Manager that the rectangle has changed and must be updated. The
  6969. rectangle lies within the window's content region and is given in the
  6970. local coordinates.
  6971.  
  6972.     For example, this procedure is useful when you're calling SizeWindow
  6973. (described above) for a document window that contains a size box or
  6974. scroll bars. Suppose yuou're going to call SizeWindow with
  6975. fUpdate=TRUE. If the window is enlarged as shown in Figure 8 above,
  6976. you'll want not only the newly created part of the content region to be
  6977. updated, but also the two rectangular areas containing the (former)
  6978. size box and scroll bars; before calling SizeWindow, you can call
  6979. InvalRect twice to accumulate those areas into the update region. In
  6980. case the window is made smaller, you'll want the new size box and
  6981. scroll bar areas to be updated, and so can similarly call InvalRect for
  6982. those areas after calling SizeWindow. See Figure 1Ø for an
  6983. iillustration of this type of update region maintenance.
  6984.  
  6985.     As another example, suppose your application scrolls up text in a
  6986. document window and wants to show new text added at the bottom of the
  6987. window. You can cause the added text to be redrawn by accumulating
  6988. that area into the update region with InvalRect.
  6989. \ InvalRgn
  6990. 5
  6991. Procedure InvalRgn (badRgn: RgnHandle);
  6992.  
  6993.     InvalRgn is the same as InvalRect (above) but for a region that has
  6994. changed rather than a rectangle.
  6995. \ ValidRect
  6996. 5
  6997. Procedure ValidRect (goodRect: Rect);
  6998.  
  6999.     ValidRect removes goodRect from the update region of the window
  7000. whose grafPort is the current port. This tells the Window Manager that
  7001. the application has already drawn the rectangle and to cancel any
  7002. updates accumulated for that area. The rectangle lies within the
  7003. window's content region and is given in local coordinates. Using
  7004. ValidRect results in better performance and less redundant redrawing in
  7005. the window.
  7006.  
  7007.     For example, suppose you've called SizeWindow (described above) with
  7008. fUpdate=TRUE for a document window that contains a size box or scroll
  7009. bars. Depending on the dimensions of the newly sized window, the new
  7010. size box and scroll bar areas may or may not have been accumulated into
  7011. the window's update region. After calling SizeWindow, you can redraw
  7012. the size box or scroll bars immediately and then call ValidRect for the
  7013. areas they occupy in case they were in fact accumulated into the update
  7014. region; this will avoid redundant drawing.
  7015. \ ValidRgn
  7016. 5
  7017. Procedure ValidRgn (goodRgn: RgnHandle);
  7018.  
  7019.     ValidRgn is the same as ValidRect (above) but for a region that has
  7020. been drawn rather than a rectangle.
  7021. \ BeginUpdate
  7022. 5
  7023. Procedure BeginUpdate (theWindow: WindowPtr);
  7024.  
  7025.     Call BeginUpdate when an update event occurs for theWindow.
  7026. BeginUpdate replaces the visRgn of the window's grafPort with the
  7027. intersection of the visRgn and the update region and then sets the
  7028. window's update region to the empty region. You would then usually
  7029. draw the entire content region, though it suffices to draw only the
  7030. visRgn; in either case, only the parts of the window that require
  7031. updating will actually be drwn on the screen. Every call to
  7032. BeginUpdate must be balanced by a call to EndUpdate. (See below, and
  7033. see "How a Window is Drawn".)
  7034. \ EndUpdate
  7035. 5
  7036. Procedure EndUpdate (theWindow: WindowPtr);
  7037.  
  7038.     Call EndUpdate to restore the normal visRgn of theWindow's grafPort,
  7039. which was changed by BeginUpdate as described above.
  7040. \ SetWRefCon
  7041. 5
  7042. Procedure SetWRefCon (theWindow: WindowPtr; data: LongInt);
  7043.  
  7044.     SetWRefCon sets theWindow's reference value to the given data.
  7045. \ GetWRefCon
  7046. 5
  7047. Function GetWRefCon (theWindow: WindowPtr) : LongInt;
  7048.  
  7049.     GetWRefCon returns theWindow's current reference value.
  7050. \ SetWindowPic
  7051. 5
  7052. Procedure SetWindowPic (theWindow: WindowPtr; pic: PicHandle);
  7053.  
  7054.     SetWindowPic stores the given picture handle in the window record
  7055. for theWindow, so that when theWindow's contents are to be drawn, the
  7056. Window Manager will draw this picture rather than generate an update
  7057. event.
  7058. \ GetWindowPic
  7059. 5
  7060. Function GetWindowPic (theWindow: WindowPtr) : PicHandle;
  7061.  
  7062.     GetWindowPic returns the handle to the picture that draws
  7063. theWindow's contents, previously stored with SetWindowPic (above).
  7064. \ PinRect
  7065. 5
  7066. Function PinRect (theRect: Rect; thePt: Point) : LongInt;
  7067.  
  7068.     PinRect "pins" thePt inside theRect: The high-order word of the
  7069. Function result is the vertical coordinate of thePt or, if thePt lies
  7070. above or below theRect, the vertical coordinate of the top or bottom of
  7071. theRect, respectively. The low-order word of the function result is
  7072. the horizontal coordinate of thePt or, if thePt lies to the left or
  7073. right of theRect, the horizontal coordinate of the left or right edge
  7074. of theRect.
  7075. \ DragGrayRgn
  7076. 5
  7077. Function DragGrayRgn (theRgn: RgnHandle; startPt: Point;
  7078.     limitRect,slopRect: Rect; axis: INTEGER; actionProc:
  7079.     ProcPtr): LongInt;
  7080.  
  7081.     Called when the mouse button is down inside theRgn, DragGrayRgn
  7082. pulls a gray outline of the region around, following the movements of
  7083. the mouse until the button is released. DragWindow calls this function
  7084. before actually moving the window, and the Control Manager routine
  7085. DragControl similarly calls it for controls. You can call it yourself
  7086. to pull around the outline of any region, and then use the information
  7087. it returns to determine where to move the region.
  7088.  
  7089.     The startPt parameter is assumed to be the point where the mouse
  7090. button was orignally pressed, in the local coordinates of the current
  7091. LimitRect and slopRect are also in the local coordinates of the current
  7092. grafPort. To explain these parameters, the concept of "offset point"
  7093. must be introduced: this is the point whose vertical and horizontal
  7094. offsets from the top left corner of the region's enclosing rectangle
  7095. are the same as those of startPt. Initially the offset point is the
  7096. same as the mouse position, but they may differ, depending on where the
  7097. user moves the mouse. DragGrayRgn will never move the offset point
  7098. outside limitRect; this limits the travel of the region's outline (but
  7099. not the movements of the mouse). SlopRect, which should completely
  7100. enclose limitRect, allows the user some "slop" in moving the mouse.
  7101. DragGrayRgn's behavior while tracking the mouse depends on the position
  7102. of the mouse with respect to these two rectangles
  7103.  
  7104.    - when the mouse is inside limitRect, the region's outline follows
  7105.      it normally. If the mouse button is released there, the region
  7106.      should be moved to the mouse position.
  7107.  
  7108.    - When the mouse is outside limitRect but inside slopRect,
  7109.      DragGrayRgn "pins" the offset point to the edge of limitRect. If
  7110.      the mouse button is released there, the region should be moved to
  7111.      this pinned location.
  7112.  
  7113.    - When the mouse is outside slopRect, the outline disappears from
  7114.      screen, but DragGrayRgn continues to follow the mouse; if it
  7115.      moves back into slopRect, the outline reappears. If the mouse
  7116.      button is released outside slopRect, the region should not be
  7117.      moved from its original position.
  7118.  
  7119.     Figure 11 illustrates what happens when the mouse is moved outside
  7120. limitRect but inside slopRect, for a rectangular region. The offset
  7121. point is pinned as the mouse position moves on.
  7122.  
  7123.     If the mouse button is released outside slopRect, DragGrayRgn
  7124. returns -32768 ($8ØØØ); otherwise, the high-order word of the value
  7125. returned contains the vertical coordinate of the ending mouse point
  7126. minus that of startPt and the low-order word contains the difference
  7127. between the horizontal coordinates.
  7128.  
  7129.     The axis parameter allows you to constrain the outline's motion to
  7130. only one axis. It has one of the following values:
  7131.  
  7132.     CONST noConstraint = Ø;     {no constraint}
  7133.           hAxis Only   = 1;     {horizontal axis only}
  7134.           vAxis Only   = 2;     {vertical axis only}
  7135.  
  7136.     If noaxis constraint is in effect, the outline will follow the
  7137. mouse's movements along the specified axis only, ignoring motion along
  7138. the other axis. With or without an axis constraint, the mouse must
  7139. still be inside the slop rectangle for the outline to appear at all.
  7140.  
  7141.     The actionProc parameter is a pointer to a procedure that defines
  7142. some action to be performed repeatedly for as long as the user holds
  7143. down the mouse button; the procedure should have no parameters. If
  7144. actionProc is NIL, DragGrayRgn simply retains control until the mouse
  7145. button is released, performing no action while the mouse button is
  7146. down.
  7147. \ CheckUpdate
  7148. 5
  7149. Function CheckUpdate (VAR the Event: EventRecord) : BOOLEAN;
  7150.  
  7151.     CheckUpdate is called by the Toolbox Event Manager. From the front
  7152. to the back in the window list, it looks for a visible window that needs
  7153. updating (that is, whose update region is not empty). If it finds one
  7154. whose window record contains a picture handle, it draws the picture
  7155. (doing all the necessary region manipulation) and looks for the next
  7156. visible window that needs updating. If it ever finds one whose window
  7157. record doesn't contain a picture handle, it stores an update event for
  7158. that window in theEvent and returns TRUE. If it never finds such a
  7159. window, it returns FALSE.
  7160. \ ClipAbove
  7161. 5
  7162. Procedure ClipAbove (window: WindowPeek);
  7163.  
  7164.     ClipAbove sets the clipRgn of the Window Manager port to be the
  7165. desktop (global variable grayRgn) intersected with the current clipRgn,
  7166. minus the structure regions of all the windows above the given window.
  7167. \ SaveOld
  7168. 5
  7169. Procedure SaveOld (window: WindowPeek);
  7170.  
  7171.     SaveOld saves the given window's current structure region and
  7172. content region for the DrawNew operation (see below). It must be
  7173. balanced by a subsequent call to DrawNew.
  7174. \ DrawNew
  7175. 5
  7176. Procedure DrawNew (window: WindowPeek; update: BOOLEAN);
  7177.  
  7178.     If the update parameter is TRUE, DrawNew updates the area.
  7179.  
  7180.     (oldStruct XOR newStruct) UNION oldContent XOR newContent)
  7181.  
  7182.     where oldStruct and oldContent are the structure and content regions
  7183. saved by the SaveOld procedures, and newStruct and newContent are the
  7184. current structure and content regions. It paints the area white and
  7185. adds it to the window's update region. If update is FALSE, it only
  7186. paints the area white.
  7187.  
  7188. (warning)
  7189.     SaveOld and DrawNew are not nestable.
  7190. \ PaintOne
  7191. 5
  7192. Procedure PaintOne (window: WindowPeek; clobberedRgn: RgnHandle);
  7193.  
  7194.     PaintOne "paints" the given window, clipped to clobberedRgn and all
  7195. windows above it: it draws the window frame and, if some content is
  7196. exposed, paints the exposed area white and adds it to the window's
  7197. update region. If the window parameter is NIL, the window is the
  7198. desktop and so is painted gray.
  7199. \ PaintBehind
  7200. 5
  7201. Procedure PaintBehind (startWindow: WindowPeek; clobberedRgn:
  7202.     RgnHandle);
  7203.  
  7204.     PaintBehind calls PaintOne (above for startWindow and all the
  7205. windows behind startWindow, clipped to clobberedRgn.
  7206. \ CalcVis
  7207. 5
  7208. Procedure CalcVis (window: WindowPeek);
  7209.  
  7210.     CalVis calculates the visRgn of the given window by starting with
  7211. its content region and subtracting the structure region of each window
  7212. in front of it.
  7213. \ CalcVisBehind
  7214. 5
  7215. Procedure CalcVisBehind (startWindow: WindowPeek; clobberedRgn:
  7216.     RegHandle;
  7217.  
  7218.     CalcVisBehind calculates the visRgns of start Window and all windows
  7219. behind startWindow that intersect with clobberedRgn. It's called after
  7220. PaintBehind (see  above).
  7221. \ TrackBox
  7222. 5
  7223. Function TrackBox (theWindow: WindowPtr; thePt: Point;
  7224.                     partCode: INTEGER) : BOOLEAN;
  7225.  
  7226.     When there’s a mouse-down event in the zoom-window box of theWindow,
  7227. the application should call TrackBox with thePt equal to the point
  7228. where the mouse button was pressed (in global coordinates, as stored
  7229. in the where field of the event record). The partCode parameter
  7230. contains the constant (either inZoomIn or inZoomOut) returned by
  7231. FindWindow. TrackBox keeps control until the mouse button
  7232. is released; it highlights the zoom-window box in the same way as
  7233. a window’s close box is highlighted. When the mouse button is released,
  7234. TrackBox unhighlights the zoom-window box and returns TRUE if
  7235. the mouse is inside the zoom-window box or FALSE if it’s outside
  7236. the box (in which case the application should do nothing).
  7237. \ ZoomWindow
  7238. 5
  7239. Procedure ZoomWindow (theWindow: WindowPtr;
  7240.                         partCode: INTEGER; front: BOOLEAN);
  7241.  
  7242.     Call ZoomWindow after a call to TrackBox that returns TRUE.
  7243. The partCode parameter contains the constant (either inZoomIn or
  7244. inZoomOut) returned by FindWindow. The window will be zoomed either
  7245. out or in, depending on the state of the window specified by partCode.
  7246. If the window is already in the state specified by partCode, ZoomWindow
  7247. does nothing. If the front parameter is TRUE, the window will be
  7248. brought to the front; otherwise, the window is left where it is.
  7249. (This means a window can be zoomed without necessarily becoming
  7250. the active window.)
  7251.  
  7252.     For best results, call the QuickDraw procedure EraseRect with the
  7253. portRect field of theWindow’s grafPort before calling ZoomWindow.
  7254.  
  7255. Warning:  Using the QuickDraw procedure SetPort, set thePort to the
  7256.           window’s port before calling ZoomWindow.
  7257.  
  7258. Note:     ZoomWindow is in no way tied to the TrackBox function and
  7259.           could just as easily be called in response to a selection
  7260.           from a menu.
  7261. \ NewControl
  7262. 6
  7263. Function NewControl (theWindow: WindowPtr; boundsRect: Rect; title:
  7264.                     Str255; visible: BOOLEAN; value: INTEGER;
  7265.                     min,max: INTEGER; procID: INTEGER; refCon: LongInt)
  7266.                     : ControlHandle;
  7267.  
  7268.  
  7269.     NewControl creates a control, adds it to the beginning of
  7270. theWindow's control list, and returns a handle to the new control. The
  7271. values passed as parameters are stored in the corresponding fields of
  7272. the control record, as described below. The field that determines
  7273. highlighting is set to Ø (no highlighting) and the pointer to the
  7274. default action procedure is set to NIL (none).
  7275.  
  7276. (note)
  7277.     The control definition function may do additional
  7278.     initialization, including changing any of the fields of
  7279.     the control record. The only standard control for which
  7280.     additional initialization is done is the scroll bar; its
  7281.     control definition function allocates space for a region
  7282.     to hold the thumb and stores the region handle in the
  7283.     contrlData field of the control record.
  7284.  
  7285.     TheWindow is the window the new control will belong to. All
  7286. coordinates pertaining to the control will be interpreted in this
  7287. window's local coordinate system.
  7288.  
  7289.     BoundsRect, given in theWindow's local coordinates, is the rectangle
  7290. that encloses the control and thus determines its size and location.
  7291. Note the following about the enclosing rectangle for the standard
  7292. controls:
  7293.  
  7294.       - Simple buttons are drawn to fit the rectangle exactly. (The
  7295.         control definition function calls the QuickDraw procedure
  7296.     FrameRoundRect.)  To allow for the tallest characters in the
  7297.     system font, there should be at least a 2Ø-point difference
  7298.     between the top and bottom coordinates of the rectangle.
  7299.  
  7300.       - For check boxes and radio buttons, there should be at least a
  7301.     16-point difference between the top and bottom coordinates.
  7302.  
  7303.       - By convention, scroll bars are 16 pixels wide, so there should
  7304.     be a 16-point difference between the left and right (or top and
  7305.     bottom) coordinates. If there isn't, the scroll bar will be
  7306.     scaled to fit the rectangle.
  7307.  
  7308.     Title is the control's title, if any (if none, you can just pass the
  7309. empty string as the title). Be sure the title will fit in the
  7310. control's enclosing rectangle; if it won't, it will be truncated on the
  7311. right for check boxes and radio buttons, or centered and truncated on
  7312. both ends for simple buttons.
  7313.  
  7314.     If the visible parameter is TRUE, NewControl draws the control.
  7315.  
  7316. (note)
  7317.     It does NOT use the standard window updating mechanism,
  7318.     but instead draws the control immediately in the window.
  7319.  
  7320.     The min and max parameters define the control's range of possible
  7321. settings; the value parameter gives the initial setting. For controls
  7322. that don't retain a setting, such as buttons, the values you supply for
  7323. these parameters will be stored in the control record but will never be
  7324. used. So it doesn't matter what values you give for those controls--Ø
  7325. for all three parameters will do. For controls that just retain an
  7326. on-or-off setting, such as check boxes or radio buttons, min should be
  7327. Ø (meaning the control is off) and max should be 1 (meaning it's on).
  7328. For dials, you can specify whatever values are appropriate for min,
  7329. max, and value.
  7330.  
  7331.     ProcID is the control definition ID, which leads to the control
  7332. definition function for this type of control. The control definition
  7333. IDs for the standard control types are listed above under "Controls and
  7334. Resources". Control definition IDs for custom control types are
  7335. discussed later under "Defining Your Own Controls".
  7336.  
  7337.     RefCon is the control's reference value, set and used only by your
  7338. application.
  7339. \ GetNewControl
  7340. 6
  7341. Function GetNewControl (controlID: INTEGER; theWindow: WindowPtr)
  7342.                         : ControlHandle;
  7343.  
  7344.     GetNewControl creates a control from a control template stored in a
  7345. resource file, adds it to the beginning of theWindow's control list,
  7346. and returns a handle to the new control. ControlID is the resource ID
  7347. of the template. GetNewControl works exactly the same as NewControl
  7348. (above), except thatt it gets the initial values for the new control's
  7349. fields from the specified control template instead of accepting them as
  7350. parameters.
  7351. \ DisposeControl
  7352. 6
  7353. Procedure DisposeControl (theControl: ControlHandle);
  7354.  
  7355.     DisposeControl removes theControl from the screen, deletes it from
  7356. its window's control list, and releases the memory occupied by the
  7357. control record and all data structures associated with the control.
  7358. \ KillControls
  7359. 6
  7360. Procedure KillControls (theWindow: WindowPtr);
  7361.  
  7362.     KillControls disposes of all controls associated with theWindow by
  7363. calling DisposeControl (above) for each.
  7364. \ SetCTitle
  7365. 6
  7366. Procedure SetCTitle (theControl: ControlHandle; title: Str255);
  7367.  
  7368.     SetCTitle sets theControl's title to the given string and redraws
  7369. the control.
  7370. \ GetCTitle
  7371. 6
  7372. Procedure GetCTitle (theControl: ControlHandle; VAR title: Str255);
  7373.  
  7374.     GetCTitle returns theControl's title as the value of the title
  7375. parameter.
  7376. \ HideControl
  7377. 6
  7378. Procedure HideControl (theControl: ControlHandle);
  7379.  
  7380.     HideControl makes theControl invisible. It fills the region the
  7381. control occupies within its window with the background pattern of the
  7382. window's grafPort. It also adds the control's enclosing rectangle to
  7383. the window's update region, so that anything else that was previously
  7384. obscured by the control will reappear on the screen. If the control is
  7385. already invisible, HideControl has no effect.
  7386. \ ShowControl
  7387. 6
  7388. Procedure ShowControl (theControl: ControlHandle);
  7389.  
  7390.     ShowControl makes theControl visible. The control is drawn in its
  7391. window but may be completely or partially obscured by overlapping
  7392. windows or other objects. If the control is already visible,
  7393. ShowControl has no effect.
  7394. \ DrawControls
  7395. 6
  7396. Procedure DrawControls (theWindow: WindowPtr);
  7397.  
  7398.     DrawControls draws all controls currently visible in theWindow. The
  7399. controls are drawn in reverse order of creation; thus in case of
  7400. overlap the earliest-created controls appear frontmost in the window.
  7401.  
  7402. (note)
  7403.     WindowManager routines such as SelectWindow, ShowWindow,
  7404.     and BringToFront do not automatically call DrawControls
  7405.     to display the window's controls. They just add the
  7406.     appropriate regions to the window's update region,
  7407.     generating an update event. Your program should always
  7408.     call DrawControls explicitly upon receiving an update
  7409.     event for a window that contains controls.
  7410. \ HiliteControl
  7411. 6
  7412. Procedure HiliteControl (theControl: ControlHandle; hiliteState:
  7413.                         INTEGER);
  7414.  
  7415.     HiliteControl changes the way theControl is highlighted. HiliteState
  7416. is an integer between Ø and 255;
  7417.  
  7418.        - A value of Ø means no highlighting.
  7419.  
  7420.        - A value between 1 and 253 is interpreted as a part code
  7421.          designating the part of the control to be highlighted.
  7422.  
  7423.        - A value of 254 or 255 means that the control is to be made
  7424.          inactive and highlighted accordingly. Usually you'll want to
  7425.          use 254, because it enables you to detect when the mouse button
  7426.          was pressed in the inactive control as opposed to not in any
  7427.          control;
  7428.          for more information, see FindControl under "Mouse Location"
  7429.          below.
  7430.  
  7431.     Hilite Control calls the control definition function to redraw the
  7432. control with its new highlighting.
  7433. \ TestControl
  7434. 6
  7435. Function TestControl (theControl: ControlHandle; thePoint: Point)
  7436.                         :  INTEGER;
  7437.  
  7438.     If theControl is visible and active, TestControl tests which part of
  7439. the control contains thePoint (in the local coordinates of the
  7440. control's window); it returns the corresponding part code, or Ø if the
  7441. point is outside the control. If the control is visible and inactive
  7442. with 254 highlighting, TestControl returns 254. If the control is
  7443. invisible, or inactive with 255 highlighting, TestControl returns Ø.
  7444. \ FindControl
  7445. 6
  7446. Function FindControl (thePoint: Point; theWindow: WindowPtr; VAR
  7447.                         whichControl: ControlHandle) : INTEGER;
  7448.  
  7449.     When the Window Manager function FindWindow reports that the mouse
  7450. button was pressed in the content region of a window, and the window
  7451. contains controls, the application should call FindControl with
  7452. theWindow equal to the window pointer and thePoint equal to the point
  7453. where the mouse button was pressed (in the window's local coordinates).
  7454. FindControl tells which of the window's controls, if any, the mouse
  7455. button was pressed in:
  7456.  
  7457.       - If it was pressed in a visible, active control, FindControl sets
  7458.         the whichControl parameter to the control handle and returns a
  7459.         part code identifying the part of the control that it was
  7460.         pressed in.
  7461.  
  7462.       - If it was pressed in a visible, inactive control with 254
  7463.         highlighting, FindControl sets whichControl to the control
  7464.         handle and returns 254 as its result.
  7465.  
  7466.       - If it was pressed in an invisible control, an inactive control
  7467.         with 255 highlighting, or not in any control, FindControl sets
  7468.         whichControl to NIL and returns Ø as its result.
  7469.  
  7470. (warning)
  7471.     Notice that FindControl expects the mouse point in the
  7472.     window's local coordinates, whereas FindWindow expects it
  7473.     in global coordinates. Always be sure to convert the
  7474.     point to local coordinates with the QuickDraw procedure
  7475.     GlobalToLocal before calling FindControl.
  7476.  
  7477. (note)
  7478.     FindControl also returns NIL for whichControl and Ø as
  7479.     its result if the window is invisible or doesn't contain
  7480.     the given point. In these cases, however, FindWindow
  7481.     wouldn't have returned this window in the first place, so
  7482.     the situation should never arise.
  7483. \ TrackControl
  7484. 6
  7485. Function TrackControl (theControl: ControlHandle; startPt: Point;
  7486.     actionProc: ProcPtr) : INTEGER;
  7487.  
  7488.     When the mouse button is pressed in a visible, active control, the
  7489. application should call TrackControl with theControl equal to the
  7490. control handle and startPt equal to the point where the mouse button
  7491. was pressed (in the local coordinates of the control's window).
  7492. TrackControl follows the movements of the mouse and responds in
  7493. whatever way is appropriate until the mouse button is released; the
  7494. exact response depends on the type of control and the part of the
  7495. control in which the mouse button was pressed. If highlighting is
  7496. appropriate, TrackControl does the highlighting, and undoes it before
  7497. returning. When the mouse button is released, TrackControl returns
  7498. with the part code if the mouse is in the same part of the control that
  7499. it was originally in, or with Ø if not (in which case the application
  7500. should do nothing.
  7501.  
  7502.     If the mouse button was pressed in an indicator, TrackControl drags
  7503. a gray outline of it to follow the mouse (by calling the Window Manager
  7504. utility function DragGrayRgn). When the mouse button is released,
  7505. TrackControl calls the control definition function to reposition the
  7506. control's indicator. The control definition function for scroll bars
  7507. responds by redrawing the thumb, calculating  the control's current
  7508. setting based on the new relative position of the thumb, and storing
  7509. the current setting in the control record; for example, if the minimum
  7510. and maximum settings are  Ø and 1Ø, and the thumb is in the middle of
  7511. the scroll bar, 5 is stored as the current setting. The application
  7512. must then scroll to the corresponding relative position in the
  7513. document.
  7514.  
  7515.     TrackControl may take additional actions beyond highlighting the
  7516. control or dragging the indicator, depending on the value passed in the
  7517. actionProc parameter, as described below. Here you'll learn what to
  7518. pass for the standard control types; for a custom control, what you
  7519. pass will depend on how the control is defined.
  7520.  
  7521.       - If actionProc is NIL, TrackControl performs no additional
  7522.         actions. This is appropriate for simple buttons, check boxes,
  7523.         radio buttons, and the thumb of a scroll bar.
  7524.  
  7525.       - ActionProc may be a pointer to an action procedure that defines
  7526.         some action to be performed repeatedly for as long as the user
  7527.         holds down the mouse button. (See below for details)
  7528.  
  7529.       - If actionProc is POINTER(-1), TrackControl looks in the control
  7530.         record for a pointer to the control's default action procedure.
  7531.         If that field of the control record contains a procedure
  7532.         pointer, TrackControl uses the action procedure it points to; if
  7533.         the field contains POINTER(-1), TrackControl calls the control
  7534.         definition function to perform the necessary action. (If the
  7535.         field contains NIL, TrackControl does nothing.)
  7536.  
  7537.     The action procedure in the control definition function is described
  7538. in the section "Defining Your Own Controls". The following paragraphs
  7539. describe only the action procedure whose pointer is passed in the
  7540. actionProc parameter or stored in the control record.
  7541.  
  7542.     If the mouse button was pressed in an indicator, the action
  7543. Procedure (if any) should have no parameters. This procedure must allow
  7544. for the fact that the mouse may not be inside the original control part.
  7545.  
  7546.     If the mouse button was pressed in a control part other than an
  7547. indicator, the action procedure should be of the form
  7548.  
  7549.     PROCEDURE MyAction (theControl: ControlHandle; partCode: INTEGER);
  7550.  
  7551.     In this case, TrackControl passes the control handle and the part
  7552. code to the action procedure. (It passes Ø in the partCode parameter if
  7553. the mouse has moved outside the original control part.)  As an example
  7554. of this type of action procedure, consider what should happen when the
  7555. mouse button is pressed in a scroll arrow or paging region in a scroll
  7556. bar. For these cases, your action procedure should examine the part
  7557. code to determine exactly where the mouse button was pressed, scroll up
  7558. or down a line or page as appropriate, and call SetCt1Value to change
  7559. the control's setting and redraw the thumb.
  7560.  
  7561. (warning)
  7562.     Since it has a different number of parameters depending
  7563.     on whether the mouse button was pressed in an indicator
  7564.     or elsewhere, the action procedure you pass to
  7565.     TrackControl (or whose pointer you store in the control
  7566.     record) can be set up for only one case or the other. If
  7567.     you store a pointer to a default action procedure in a
  7568.     control record, be sure it will be used only when
  7569.     appropriate for that type of action procedure. The only
  7570.     way to specify actions in response to all mouse-down
  7571.     events in a control, regardless of whether they're in an
  7572.     indicator, is via the control definition function.
  7573. \ MoveControl
  7574. 6
  7575. Procedure MoveControl (theControl: ControlHandle; h,v: INTEGER);
  7576.  
  7577.     MoveControl moves theControl to a new location within its window.
  7578. The top left corner of the control's enclosing rectangle is moved to the
  7579. horizontal and vertical coordinates h and v (given in the local
  7580. coordinates of the control's window);  the bottom right corner is
  7581. adjusted accordingly, to keep the size of the rectangle the same as
  7582. before. If the control is currently visible, it's hidden and then
  7583. redrawn at its new location.
  7584.  
  7585. \ DragControl
  7586. 6
  7587. Procedure DragControl (theControl: ControlHandle; startPt: Point;
  7588.                         limitRect,slopRect: Rect; axis: INTEGER);
  7589.  
  7590.     Called with the mouse button down inside theControl, DragControl
  7591. pulls a gray outline of the control around the screen, following the
  7592. movements of the mouse until the button is released. When the mouse
  7593. button is released, DragControl calls MoveControl to move the control
  7594. to the location to which it was dragged.
  7595.  
  7596. (note)
  7597.     Before beginning to follow the mouse, DragControl calls
  7598.     the control definition function to allow it to do its own
  7599.     "custom dragging" if it chooses. If the definition
  7600.     function doesn't choose to do any custom dragging,
  7601.     DragControl uses the default method of dragging described
  7602.     here.
  7603.  
  7604.     DragControl calls the Window Manager utility function DragGrayRgn
  7605. and then moves the control accordingly. The startPt, limitRect,
  7606. slopRect, and axis parameters have the same meaning as for DragGrayRgn.
  7607. These parameters are reviewed briefly below; see the description of
  7608. DragGrayRgn in the Window Manager manual for more details.
  7609.  
  7610.       - StartPt parameter is assumed to be the point where the mouse
  7611.         button was originally pressed, in the local coordinates of the
  7612.         control's window.
  7613.  
  7614.       - LimitRect limits the travel of the control's outline, and should
  7615.         normally coincide with or be contained within the window's
  7616.         content region.
  7617.  
  7618.       - SlopRect allows the user some "slop" in moving the mouse; it
  7619.         should completely enclose limitRect.
  7620.  
  7621.       - The axis parameter allows you to constrain the control's motion
  7622.         to only one axis. It has one of the following values:
  7623.  
  7624.     CONST noConstraint  =   Ø;  {no constraint}
  7625.           hAxis Only    =   1;  {horizontal axis only}
  7626.           vAxis Only    =   2;  {vertical axis only}
  7627. \ SizeControl
  7628. 6
  7629. Procedure SizeControl (theControl: ControlHandle; w,h: INTEGER);
  7630.  
  7631.     SizeControl changes the size of theControl's enclosing rectangle.
  7632. The bottom right corner of the rectangle is adjusted to set the
  7633. rectangle's width and height to the number of pixels specified by w and
  7634. h; the position of the top left corner is not changed. If the control
  7635. is currently visible, it's hidden and then redrawn in its new size.
  7636. \ SetCtlValue
  7637. 6
  7638. Procedure SetCtlValue (theControl: ControlHandle; theValue: INTEGER);
  7639.  
  7640.     SetCtlValue sets theControl's current setting to theValue and
  7641. redraws the control to reflect the new setting. For check boxes and
  7642. radio buttons, the value 1 fills the control with the appropriate mark,
  7643. and Ø clears it. For scroll bars, SetCtlValue redraws the thumb where
  7644. appropriate.
  7645.  
  7646.     If the specified value is out of range, it's forced to the nearest
  7647. endpoint of the current range (that is, if theValue is less than the
  7648. minimum setting, SetCtlValue sets the current setting to the minimum;
  7649. if theValue is greater than the maximum setting, it sets the current
  7650. setting to the maximum.
  7651. \ GetCtlValue
  7652. 6
  7653. Function GetCtlValue (theControl: ControlHandle) : INTEGER;
  7654.  
  7655.     GetCtlValue returns theControl's current setting.
  7656. \ SetCtlMin
  7657. 6
  7658. Procedure SetCtlMin (theControl: ControlHandle; minValue: INTEGER;
  7659.  
  7660.     SetCtlMin sets theControl's minimum setting to minValue and redraws
  7661. the control to reflect the new range. If the control's current setting
  7662. is less than minValue, the setting is changed to the new minimum.
  7663. \ GetCtlMin
  7664. 6
  7665. Function GetCtlMin (theControl: ControlHandle) : INTEGER;
  7666.  
  7667.     GetCtlMin returns theControl's minimum setting.
  7668. \ SetCtlMax
  7669. 6
  7670. Procedure SetCtlMax (theControl: ControlHandle; maxValue: INTEGER);
  7671.  
  7672.     SetCtlMax sets theControl maximum setting to maxValue and redraws
  7673. the control to reflect the new range. If maxValue is less than the
  7674. control's current setting, the setting is changed to the new maximum.
  7675. \ GetCtlMax
  7676. 6
  7677. Function GetCtlMax (theControl: ControlHandle) : INTEGER;
  7678.  
  7679.     GetCtlMax returns theControl's maximum setting.
  7680. \ SetCRefCon
  7681. 6
  7682. Procedure SetCRefCon (theControl: ControlHandle; data: LongInt);
  7683.  
  7684.     SetCRefCon sets theControl's reference value to the given data.
  7685. \ GetCRefCon
  7686. 6
  7687. Function GetCRefCon (theControl: ControlHandle) : LongInt;
  7688.  
  7689.     GetCRefCon returns theControl's current reference value.
  7690. \ SetCtlAction
  7691. 6
  7692. Procedure SetCtlAction (theControl: ControlHandle; actionProc:
  7693.                         ProcPtr);
  7694.  
  7695.     SetCtlAction sets theControl's default action procedure to
  7696. actionProc.
  7697. \ GetCtlAction
  7698. 6
  7699. Function GetCtlAction (theControl: ControlHandle) : ProcPtr;
  7700.  
  7701.     GetCtlAction returns a pointer to theControl's default action
  7702. Procedure, if any. (It returns whatever is in that field of the
  7703. control record.)
  7704.  
  7705.  
  7706. The Control Definition Function
  7707. -------------------------------
  7708.  
  7709.     The control definition function may be written in Pascal or assembly
  7710. language; the only requirement is that its entry point must be at the
  7711. beginning. You can give your control definition function any name you
  7712. like. Here's how you would declare one named MyControl:
  7713.  
  7714.     FUNCTION MyControl (varCode: INTEGER; theControl; ControlHandle;
  7715.                         message: INTEGER; param: LongInt) : LongInt;
  7716.  
  7717. VarCode is the variation code, as described above.
  7718.  
  7719. TheControl is a handle to the control that the operation will affect.
  7720.  
  7721. The message parameter identifies the desired operation. It has one of
  7722. the following values:
  7723.  
  7724.   CONST drawCntl = Ø;   {draw the control (or control part)}
  7725.     testCntl     = 1;   {test where mouse button was pressed}
  7726.     calcCrgns    = 2;   {calculate control's region (or indicator's)}
  7727.     initCntl     = 3;   {do any additional control initialization}
  7728.     dispCntl     = 4;   {take any additional disposal actions}
  7729.     posCntl      = 5;   {reposition control's indicator and update it}
  7730.     thumbCntl    = 6;   {calculate parameters for dragging indicator}
  7731.     dragCntl     = 7;   {drag control (or its indicator)}
  7732.     autoTrack    = 8;   {execute control's action procedure}
  7733.  
  7734.     As described below in the discussions of the routines that perform
  7735. these operations, the value passed for param, the last parameter of the
  7736. control definition function, depends on the operation. Where it's not
  7737. mentioned below, this parameter is ignored. Similarly, the control
  7738. definition function is expected to return a function result only where
  7739. indicated; in other cases, the function should return Ø.
  7740.  
  7741. (note)
  7742.     "Routine" here does not necessarily mean a procedure or
  7743.      function. While it's a good idea to set these up as
  7744.      subprograms inside the control definition function,
  7745.      you're not required to do so.
  7746. \ UpdtControl
  7747. 6
  7748. Procedure UpdtControl (theWindow: WindowPtr; updateRgn: RgnHandle);
  7749.  
  7750.     UpdtControl is a faster version of the DrawControls procedure.
  7751. Instead of drawing all of the controls in theWindow, UpdtControl
  7752. draws only the controls that are in the specified update region.
  7753. UpdtControl is called in response to an update event, and is usually
  7754. bracketed by calls to the Window Manager procedures BeginUpdate and
  7755. EndUpdate. UpdateRgn should be set to the visRgn of theWindow’s port
  7756. (for more details, see the BeginUpdate procedure in the Window Manager
  7757. chapter).
  7758.  
  7759. Note:  In general, controls are in a dialog box and are automatically
  7760. drawn by the DrawDialog procedure.
  7761. \ Draw1Control
  7762. 6
  7763. Procedure Draw1Control (theControl: ControlHandle);
  7764.  
  7765.     Draw1Control draws the specified control if it’s visible within the
  7766. window.
  7767. \ InitMenus
  7768. 7
  7769. Procedure InitMenus;
  7770.  
  7771.     InitMenus initializes the Menu Manager. It allocates space for the
  7772. menu list (a relocatable block on the heap large enough for the maximum
  7773. size menu list), and draws the (empty) menu bar. Call InitMenus once
  7774. before all other Menu Manager routines. An application should never
  7775. have to call this procedure more than once; to start afresh with all
  7776. new menus, use ClearMenuBar.
  7777.  
  7778. (note)
  7779.     The Window Manager initialization procedure InitWindows
  7780.     has already drawn the empty menu bar; InitMenus redraws
  7781.     it.
  7782. \ NewMenu
  7783. 7
  7784. Function NewMenu (menuID: INTEGER; MenuTitle: Str255) : MenuHandle;
  7785.  
  7786.     NewMenu allocates space for a new menu with the given menu ID and
  7787. title, and returns a handle to it. It sets up the menu to use the
  7788. standard menu definition procedure. The new menu (which is created
  7789. empty) is not installed in the menu list. To use this menu, you must
  7790. first call AppendMenu or AddResMenu to fill it with items, InsertMenu
  7791. to place it in the menu list, and DrawMenuBar to update the menu bar to
  7792. include the new title.
  7793.  
  7794.     Application menus should always have positive menu IDs. Negative
  7795. menu IDs are reserved for menus belonging to desk accessories. No menu
  7796. should ever have a menu ID of Ø.
  7797.  
  7798.     If you want to set up the title of the Apple menu from your program
  7799. instead of reading it in from a resource file, you can use the
  7800. predefined constant appleMark (equal to $14, the value of the apple
  7801. symbol). For example, you can declare the string variable
  7802.  
  7803.     VAR myTitle: STRING[1];
  7804.  
  7805. and do the following:
  7806.  
  7807.     myTitle := ' ';
  7808.     myTitle[1] := CHR(appleMark)
  7809.  
  7810.     To release the memory occupied by a menu that you created with
  7811. NewMenu, call DisposeMenu.
  7812. \ GetMenu
  7813. 7
  7814. Function GetMenu (resourceID: INTEGER) : MenuHandle;
  7815.  
  7816.     GetMenu returns a menu handle for the menu having the given resource
  7817. ID. It calls the Resource Manager to read the menu from the resource
  7818. file into a menu record in memory. It stores the handle to the menu
  7819. definition procedure in the menu record, reading the procedure from the
  7820. resource file into memory if necessary. To use this menu, you must
  7821. call InsertMenu to place it in the menu list and DrawMenuBar to update
  7822. the menu bar to include the new title.
  7823.  
  7824. (warning)
  7825.     Only call GetMenu once for a particular menu. If you
  7826.     need the menu handle to a menu that's already in memory,
  7827.     use the Resource Manager function GetResource.
  7828.  
  7829.     To release the memory occupied by a menu that you read from a
  7830. resource file with GetMenu, use the Resource Manager procedure
  7831. ReleaseResource.
  7832. \ DisposeMenu
  7833. 7
  7834. Procedure DisposeMenu (theMenu: MenuHandle);
  7835.  
  7836.     Call DisposeMenu to release the memory occupied by a menu that you
  7837. allocated with NewMenu. (For menus read from a resource file with
  7838. GetMenu, use the Resource Manager procedure ReleaseResource instead.)
  7839. This is useful if you've created temporary menus that you no longer
  7840. need.
  7841.  
  7842. (warning)
  7843.     Make sure you remove the menu from the menu list (with
  7844.     DeleteMenu) before disposing of it. Also be careful not
  7845.     to use the menu handle after disposing of the menu.
  7846.  
  7847.  
  7848. \ AppendMenu
  7849. 7
  7850. Procedure AppendMenu (theMenu: MenuHandle; data: Str255);
  7851.  
  7852.     AppendMenu adds an item or items to the end of the given menu, which
  7853. must previously have been allocated by NewMenu or read from a resource
  7854. file by GetMenu. The data string consists of the text of the menu
  7855. item; it may be blank but should not be the null string. If it begins
  7856. with a hyphen (-), the item will be a dividing line across the width of
  7857. the menu. As described in the section "Creating a Menu in Your
  7858. Program", the following meta-characters may be embedded in the data
  7859. string:
  7860.  
  7861.    Meta-character     Usage
  7862.    --------------     -----
  7863.  
  7864.     ; or Return       Separates multiple items
  7865.     ^                 Followed by an icon number, adds that icon to
  7866.                       the item
  7867.     !                 Followed by a character, marks the item with
  7868.                       that character
  7869.     <                 Followed by B, I, U, O, or S, sets the
  7870.                       character style of the item
  7871.     /                 Followed by a character, associates a keyboard
  7872.                       equivalent with the item
  7873.     (                 Disables the item
  7874.  
  7875.     Once items have been appended to a menu, they cannot be removed or
  7876. rearranged. AppendMenu works properly whether or not the menu is in
  7877. the menu list.
  7878. \ AddResMenu
  7879. 7
  7880. Procedure AddResMenu (theMenu: MenuHandle; theType: ResType);
  7881.  
  7882.     AddResMenu searches all open resource files for resources of type
  7883. theType and appends the names of all resources it finds to the given
  7884. menu. Each resource name appears in the menu as an enabled item,
  7885. without an icon or mark, and in the normal character style. The
  7886. standard Menu Manager calls can be used to get the name or change its
  7887. appearance, as described below under "Controlling Items' Appearance".
  7888.  
  7889. (note)
  7890.     So that you can have resources of the given type that
  7891.     won't appear in the menu, any resource names that begin
  7892.     with a period (.) or a percent sign (%) aren't apppended
  7893.     by AddResMenu.
  7894.  
  7895.     Use this procedure to fill a menu with the names of all available
  7896. fonts or desk accessories. For example, if you declare a variable as
  7897.  
  7898.     VAR fontMenu: MenuHandle;
  7899.  
  7900. you can set up a menu containing all font names as follows:
  7901.  
  7902.     fontMenu := NewMenu(5,'Fonts');
  7903.     AddResMenu(fontMenu,"FONT')
  7904. \ InsertResMenu
  7905. 7
  7906. Procedure InsertResMenu (theMenu: MenuHandle; theType: ResType;
  7907.                         afterItem: INTEGER);
  7908.  
  7909.     InsertResMenu is the same as AddRes˜enu (above) except that it
  7910. inserts the resource names in the menu where specified by the afterItem
  7911. parameter:  if afterItem is Ø, the names are inserted before the first
  7912. menu item; if it's the item number of an item in the menu, they're
  7913. inserted after that item; if it's equal to or greater than the last
  7914. item number, they're appended to the menu.
  7915.  
  7916. (note)
  7917.     InsertResMenu inserts the names in the reverse of the
  7918.     order that AddResMenu appends them. For consistency
  7919.     between the applications in the appearance of menus, use
  7920.     AddResMenu instead of InsertResMenu if possible.
  7921. \ InsertMenu
  7922. 7
  7923. Procedure InsertMenu (theMenu: MenuHandle; before ID: INTEGER);
  7924.  
  7925.     InsertMenu inserts a menu into the menu list before the menu whose
  7926. menu ID equals beforeID. If beforeID is Ø (or isn't the ID of any menu
  7927. in the menu list), the new menu is added after all others. If the menu
  7928. is already in the menu list or the menu list is already full, InsertMenu
  7929. does nothing. Be sure to call DrawMenuBar to update the menu bar.
  7930. \ DrawMenuBar
  7931. 7
  7932. Procedure DrawMenuBar;
  7933.  
  7934.     DrawMenuBar redraws the menu bar according to the menu list,
  7935. incorporating any changes since the last call to DrawMenuBar. Any
  7936. highlighted menu title remains highlighted when drawn by DrawMenuBar.
  7937. This procedure should always be called after a sequence of InsertMenu
  7938. or DeleteMenu calls, and after ClearMenuBar, SetMenuBar, or any other
  7939. routine that changes the menu list.
  7940. \ DeleteMenu
  7941. 7
  7942. Procedure DeleteMenu (menuID: INTEGER);
  7943.  
  7944.     DeleteMenu deletes a menu from the menu list. If there's no menu
  7945. with the given menu ID in the menu list, DeleteMenu has no effect. Be
  7946. sure to call DrawMenuBar to update the menu bar; the menu titles
  7947. following the deleted menu will move over to fill the vacancy.
  7948.  
  7949. (note)
  7950.     DeleteMenu simply removes the menu from the list of
  7951.     currently available menus; it doesn't release the memory
  7952.     occupied by the menu data structure.
  7953. \ ClearMenuBar
  7954. 7
  7955. Procedure ClearMenuBar;
  7956.  
  7957.  
  7958.     Call ClearMenuBar to remove all menus from the menu list when you
  7959. want to start afresh with all new menus. Be sure to call DrawMenuBar to
  7960. update the menu bar.
  7961.  
  7962. (note)
  7963.     ClearMenuBar, like Delete Menu, doesn't release the memory
  7964.     occupied by the menu data structures; it merely removes
  7965.     them from the menu list.
  7966.  
  7967.     You don't have to call ClearMenuBar at the beginning of your
  7968. program, because InitMenus clears the menu list for you.
  7969. \ GetNewMBar
  7970. 7
  7971. Function GetNewMBar (menuBarID: INTEGER) : Handle;
  7972.  
  7973.     GetNewMBar creates a menu list as defined by the menu bar resource
  7974. having the given resource ID, and returns a handle to it. If the
  7975. resource isn't already in memory, GetNewMBar reads it into memory from
  7976. the resource file. It calls GetMenu to get each of the individual
  7977. menus.
  7978.  
  7979.     To make the menu list created by  GetNew˜Bar the  current menu list,
  7980. call SetMenuBar. To release the memory occupied by the menu list, use
  7981. the Memory Manager procedure DisposHandle.
  7982.  
  7983. (warning)
  7984.  
  7985.     You don't have to know the indivudual menu IDs to use
  7986.     GetNewMBar, but that doesn't mean you don't have to know
  7987.     them at all:  to do anything further with a particular
  7988.     menu, you have to know its ID or its handle (which you
  7989.     can get by passing the ID to GetMHandle, as described
  7990.     below under "Miscellaneous Routines").
  7991.  
  7992.  
  7993. \ GetMenuBar
  7994. 7
  7995. Function GetMenuBar : Handle;
  7996.  
  7997.     GetMenuBar creates a copy of the current menu list and returns a
  7998. handle to the copy. You can then add or remove menus from the menu list
  7999. (with InsertMenu, DeleteMenu, or ClearMenuBar), and later restore the
  8000. saved menu list with SetMenuBar. To release the memory occupied by the
  8001. saved menu list, use the Memory Manager procedure DisposHandle.
  8002.  
  8003. (warning)
  8004.     GetMenuBar doesn't copy the menus themselves, only a list
  8005.     containing their handles. Do not dispose of any menus
  8006.     that might be in a saved menu list.
  8007. \ SetMenuBar
  8008. 7
  8009. Procedure SetMenuBar (menuList: Handle);
  8010.  
  8011.     SetMenuBar copies the given menu list to the current menu list. You
  8012. can use this procedure to restore a menu list previously saved by
  8013. GetMenuBar, or pass it a handle returned by GetNewMBar. Be sure to
  8014. call DrawMenuBar to update the menu bar.
  8015. \ MenuSelect
  8016. 7
  8017. Function MenuSelect (startPt: Point) : LONGINT;
  8018.  
  8019.     When there's a mouse-down event in the menu bar, the application
  8020. should call MenuSelect with startPt equal to the point (in global
  8021. coordinates) where the mousebutton was pressed.  MenuSelect keeps
  8022. control until the mouse button is released, tracking the mouse, pulling
  8023. down menus as needed, and highlighting enabled menu items under the
  8024. cursor. When the mouse button is released over an enabled item in an
  8025. application menu, MenuSelect returns a long integer whose high-order
  8026. word is the menu ID of the menu, and whose low-order word is the menu
  8027. item number for the item chosen (see Figure 3). It leaves the selected
  8028. menu title highlighted. After performing the chosen task, your
  8029. application should call HiliteMenu(Ø) to remove the highlighting from
  8030. the menu title.
  8031.  
  8032.     If no choice is made, MenuSelect returns Ø in the high-order word of
  8033. the long integer, and the low-order word is undefined. This includes
  8034. the case where the mouse button is released over a disabled menu item
  8035. (such as Cut, Copy, Clear, or one of the dividing lines in Figure 3),
  8036. over any menu title, or outside the menu.
  8037.  
  8038.     If the mouse button is released over an enabled item in a menu
  8039. belonging to a desk accessory, MenuSelect passes the menu ID and item
  8040. number to the Desk Manager procedure SystemMenu for processing, and
  8041. returns Ø to your application in the high-order word of the result.
  8042. \ MenuKey
  8043. 7
  8044. Function MenuKey (ch: CHAR) : LONGINT;
  8045.  
  8046.     MenuKey maps the given character to the associated menu and item for
  8047. that character. When you get a key-down event with the Command key
  8048. held down--or an auto-key event, if the command being invoked is
  8049. repeatable--call MenuKey with the character that was typed. MenuKey
  8050. highlights the appropriate menu title, and returns a long integer
  8051. containing the menu ID in its high-order word and the menu item number
  8052. in its low-order word, just as MenuSelect does (see Figure 3 above).
  8053. After performing the chosen task, your application should call
  8054. HiliteMenu(Ø) to remove the highlighting from the menu title.
  8055.  
  8056.     If the given character isn't associated with any enabled menu item
  8057. currently in the menu list, MenuKey returns Ø in the high-order word of
  8058. the long integer, and the low-order word is undefined.
  8059.  
  8060.     If the given character involes a menu item in a menu belonging to a
  8061. desk accessory, MenuKey (like MenuSelect) passes the menu ID and item
  8062. number to the Desk Manager procedure SystemMenu for processing, and
  8063. returns Ø to your application in the high-order word of the result.
  8064.  
  8065. (note)
  8066.     There should never be more than one item in the menu list
  8067.     with the same keyboard equivalent, but if there is,
  8068.     MenuKey returns the first such item it encounters,
  8069.     scanning the menus from right to left and their items
  8070.     from top to bottom.
  8071. \ HiliteMenu
  8072. 7
  8073. Procedure HiliteMenu (menuID: INTEGER);
  8074.  
  8075.     Hilite Menu highlights the title of the given menu, or does nothing
  8076. if the title is already highlighted. Since only one menu title can be
  8077. highlighted at a time, it unhighlights any previously highlighted menu
  8078. title. If MenuID is Ø (or isn't the ID of any menu in the menu list),
  8079. HiliteMenu simply unhighlights whichever menu title is highlighted (if
  8080. any).
  8081.  
  8082.     After MenuSelect or MenuKey, your application should perform the
  8083. chosen task and then call HiliteMenu(Ø) to unhighlight the chosen menu
  8084. title.
  8085. \ SetItem
  8086. 7
  8087. Procedure SetItem (theMenu: MenuHandle; item: INTEGER; itemString:
  8088.     Str255);
  8089.  
  8090.     SetItem changes the text of the given menu item to itemString. It
  8091. doesn't recognize the meta-characters used in AppendMenu; if you
  8092. include them in itemString, they will appear in the text of the menu
  8093. item. The attributes already in effect for this item--its character
  8094. style, icon, and so on--remain in effect. ItemString may be blank but
  8095. should not be the null string.
  8096.  
  8097. (note)
  8098.     It's good practice to store the text of itemString in a
  8099.     resource file instead of passing it directly.
  8100.  
  8101.     Use SetItem to flip between two alternative menu items--for example,
  8102. to change "Show Clipboard" top "Hide Clipboard" when the Clipboard is
  8103. already showing.
  8104.  
  8105. (note)
  8106.     To avoid confusing the user, don't capriciously change
  8107.     the text of menu items.
  8108. \ GetItem
  8109. 7
  8110. Procedure GetItem (theMenu: MenuHandle; item: INTEGER; VAR itemString:
  8111.     Str255);
  8112.  
  8113.     GetItem returns the text of the given menu item in itemString. It
  8114. doesn't place any meta-characters in the string. This procedure is
  8115. useful for getting the name of a menu item that was installed with
  8116. AddResMenu or InsertResMenu.
  8117. \ DisableItem
  8118. 7
  8119. Procedure DisableItem (theMenu: MenuHandle; item: INTEGER);
  8120.  
  8121.     Given a menu item number in the item parameter, DisableItem disables
  8122. that menu item; given Ø in the item parameter, it disables the entire
  8123. menu.
  8124.  
  8125.     Disabled menu items appear dimmed and are not highlighted when the
  8126. cursor moves over them. MenuSelect and MenuKey return Ø in the high-
  8127. order word of their result if the user attempts to invoke a disabled
  8128. item. Use DisableItem to disable all menu choices that aren't
  8129. appropriate at a given time (such as a Cut command when there's no text
  8130. selection).
  8131.  
  8132.     All menu items are initially enabled unless you specify otherwise
  8133. (such as by using the "(" meta-character in a call to AppendMenu).
  8134.  
  8135.     Every menu item in a disabled menu is dimmed. The menu title is
  8136. also dimmed, but you must call DrawMenuBar to update the menu bar to
  8137. show the dimmed title.
  8138. \ EnableItem
  8139. 7
  8140. Procedure EnableItem (theMenu:  MenuHandle; item: INTEGER);
  8141.  
  8142.     Given a menu item number in the item parameter, EnableItem enables
  8143. the item; given 0 in the item parameter, it enables the entire menu.
  8144. (The item or menu may have been disabled with the DisableItem procedure,
  8145. or the item may have been disabled with the "(" meta-character in the
  8146. AppendMenu string.)  The item or menu title will no longer appear
  8147. dimmed and can be chosen like any other enabled item or menu.
  8148. \ CheckItem
  8149. 7
  8150. Procedure CheckItem (theMenu:  MenuHandle; item:  INTEGER; checked:
  8151.             BOOLEAN);
  8152.  
  8153.     CheckItem places or removes a check mark at the left of the given
  8154. menu item. After you call CheckItem with checked=TRUE, a check mark
  8155. will appear each subsequent time the menu is pulled down. Calling
  8156. CheckItem with checked=FALSE removes the check mark from the menu item
  8157. (or, if it's marked with a different character, removes that mark).
  8158.  
  8159.     Menu items are initially unmarked unless you specify otherwise (such
  8160. as with the "!" meta-character in a call to AppendMenu).
  8161. \ SetItemMark
  8162. 7
  8163. Procedure SetItemMark (theMenu: MenuHandle; item: INTEGER; markChar:
  8164.              CHAR);
  8165.  
  8166.     SetItemMark marks the given menu item in a more general manner than
  8167. CheckItem. It allows you to place any character in the system font,
  8168. not just the check mark, to the left of the item. You can specify some
  8169. useful values for the markChar parameter with the following predefined
  8170. constants:
  8171.  
  8172.        CONST noMark      = 0;      {NUL character, to remove a mark}
  8173.              commandMark = $11;    {Command key symbol}
  8174.              checkMark   = $12;    {check mark}
  8175.              diamondMark = $13;    {diamond symbol}
  8176.              appleMark   = $14;    {apple symbol}
  8177. \ GetItemMark
  8178. 7
  8179. Procedure GetItemMark (theMenu: MenuHandle; item: INTEGER; VAR
  8180.             markChar: CHAR);
  8181.  
  8182.     GetItemMark returns in markChar whatever character the given menu
  8183. item is marked with, or the NUL character (ASCII code 0) if no mark is
  8184. present.
  8185. \ SetItemIcon
  8186. 7
  8187. Procedure SetItemIcon (theMenu: MenuHandle; item: INTEGER; icon: Byte);
  8188.  
  8189.     SetItemIcon associates the given menu item with an icon. It sets
  8190. the item's icon number to the given value (an integer from 1 to 255).
  8191. The Menu Manager adds 256 to the icon number to get the icon's resource
  8192. ID, which it passes to the Resource Manager to get the corresponding
  8193. icon.
  8194.  
  8195. (warning)
  8196.        If you deal directly with the Resource Manager to read or
  8197.        store menu icons, be sure to adjust your icon numbers
  8198.        accordingly.
  8199.  
  8200. Menu items initially have no icons unless you specify otherwise (such
  8201. as with the "^" meta-character in a call to AppendMenu).
  8202. \ GetItemIcon
  8203. 7
  8204. Procedure GetItemIcon (theMenu: MenuHandle; item: INTEGER; VAR icon:
  8205.                          Byte);
  8206.  
  8207.     GetItemIcon returns the icon number associated with the given menu
  8208. item, as an integer from 1 to 255, or 0 if the item has not been
  8209. associated with an icon. The icon number is 256 less than the icon's
  8210. resource ID.
  8211. \ SetItemStyle
  8212. 7
  8213. Procedure SetItemStyle (theMenu: MenuHandle; item: INTEGER; chStyle:
  8214.                         Style);
  8215.  
  8216.     SetItemStyle changes the character style of the given menu item to
  8217. chStyle. For example:
  8218.  
  8219.     SetItemStyle(thisMenu,1,[bold,italic])     {bold and italic}
  8220.  
  8221.     Menu items are initially in the normal character style unless you
  8222. specify otherwise (such as with the "<" meta-character in a call to
  8223. AppendMenu).
  8224. \ GetItemStyle
  8225. 7
  8226. Procedure GetItemStyle (theMenu: MenuHandle; item: INTEGER; VAR
  8227.                         chStyle: Style);
  8228.  
  8229.     GetItemStyle returns the character style of the given menu item in
  8230. chStyle.
  8231. \ CalcMenuSize
  8232. 7
  8233. Procedure CalcMenuSize (theMenu: MenuHandle);
  8234.  
  8235.     You can use CalcMenuSize to recalculate the horizontal and vertical
  8236. dimensions of a menu whose contents have been changed (and store them
  8237. in the appropriate fields of the menu record). CalcMenuSize is called
  8238. internally by the Menu Manager after every AppendMenu, SetItem,
  8239. SetItemIcon, and SetItemStyle call.
  8240. \ CountMItems
  8241. 7
  8242. Function CountMItems (TheMenu: MenuHandle): INTEGER;
  8243.  
  8244.     CountMItems returns the number of menus item in the given menu.
  8245. \ GetMHandle
  8246. 7
  8247. Function GetMHandle (menuID: INTEGER) : MenuHandle;
  8248.  
  8249.     Given the menu ID of a menu currently installed in the menu list,
  8250. GetMHandle returns a handle to that menu; given any other menu ID, it
  8251. returns NIL.
  8252. \ FlashMenuBar
  8253. 7
  8254. Procedure FlashMenuBar (menuID: INTEGER);
  8255.  
  8256.     If menuID is 0 (or isn't the ID of any menu in the menu list),
  8257. FlashMenuBar inverts the entire menu bar; otherwise, it inverts the
  8258. title of the given menu.
  8259. \ SetMenuFlash
  8260. 7
  8261. Procedure SetMenuFlash (count: INTEGER);
  8262.  
  8263.     When the mouse button is released over an enabled menu item, the
  8264. item blinks briefly to confirm the choice. Normally your application
  8265. shouldn't be concerned with this blinking; the user sets it with the
  8266. Control Panel desk accessory. If you're writing a desk accessory like
  8267. the Control Panel, though, SetMenuFlash allows you to control the
  8268. duration of this blinking. Count is the number of times menu items
  8269. will blink; it's initially 3 if the user hasn't changed it. A count of
  8270. 0 disables blinking. Values greater than 3 can be annoyingly slow.
  8271.  
  8272. (warning)
  8273.     Don't call SetMenuFlash from your main program.
  8274.  
  8275. (note)
  8276.     Items in both standard and nonstandard menus blink when
  8277.     chosen. The appearance of the blinking for a nonstandard
  8278.     menu depends on the menu definition procedure, as
  8279.     described below.
  8280. \ InsMenuItem
  8281. 7
  8282. Procedure InsMenuItem (theMenu: MenuHandle; itemString: Str255;
  8283.                         afterItem: INTEGER);
  8284.  
  8285.     InsMenuItem inserts an item or items into the given menu where
  8286. specified by the afterItem parameter. If afterItem is 0, the items
  8287. are inserted before the first menu item; if it’s the item number of an
  8288. item in the menu, they’re inserted after that item; if it’s equal to or
  8289. greater than the last item number, they’re appended to the menu.
  8290.  
  8291. Warning:  Only the items contained in itemString are sorted.
  8292.  
  8293.     The contents of itemString are parsed as in the AppendMenu
  8294. Procedure. Multiple items are inserted in the reverse of their order in
  8295. itemString.
  8296. \ DelMenuItem
  8297. 7
  8298. Procedure DelMenuItem (theMenu: MenuHandle; item: INTEGER);
  8299.  
  8300.     DelMenuItem deletes the specified item from the given menu.
  8301.  
  8302. Note:  DelMenuItem is intended for maintaining dynamic menus (such as
  8303.        a list of open windows). It should not be used for disabling
  8304.        items; you should use DisableItem instead.
  8305. \ TEInit
  8306. 8
  8307. Procedure TEInit;
  8308.  
  8309.     TEInit initializes TextEdit by allocating a handle for the TextEdit
  8310. scrap. The scrap is initially empty. Calll this procedure once and
  8311. only once at the beginning of your program.
  8312.  
  8313. (note)
  8314.       You should call TEInit even if your application doesn't
  8315.       use TextEdit, so that desk accessories and dialog and
  8316.       alert boxes will work correctly.
  8317. \ TENew
  8318. 8
  8319. Function TENew (destRect, viewRect: Rect) : TEHandle;
  8320.  
  8321.     TENew allocates a handle for the text, creates and initializes an
  8322. edit record, and returns a handle to the new edit record. DestRect and
  8323. viewRect are the destination and view rectangles, respectively. Both
  8324. rectangles are specified in the current grafPort's coordinates. The
  8325. destination rectangle must always be at least as wide as the first
  8326. character drawn (about 20 pixels is usually a good width). The view
  8327. rectangle must not be empty (for example, don't make its right edge
  8328. less than its left edge if you don't want any text visible--specify a
  8329. rectangle off the screen instead).
  8330.  
  8331.     Call TENew once for every edit record you want allocated. The edit
  8332. record incorporates the drawing environment of the grafPort, and is
  8333. initialized for left-justified, single-spaced text with an insertion
  8334. point at character position 0.
  8335.  
  8336. (note)
  8337.       The caret won't appear until you call TEActivate.
  8338. \ TEDispose
  8339. 8
  8340. Procedure TEDispose (hTE: TEHandle);
  8341.  
  8342.     TEDispose releases the memory allocated for the edit record and text
  8343. specified by hTE. Call this procedure when you're completely through
  8344. with an edit record.
  8345. \ TESetText
  8346. 8
  8347. Procedure TESetText (text: Ptr; length: LONGINT; hTE: TEHandle);
  8348.  
  8349.     TESetText incorporates a copy of the specified text into the edit
  8350. record specified by hTE. The text parameter points to the text, and
  8351. the length paramenter indicates the number of characters in the text.
  8352. The selection range is set to an insertion point at the end of the
  8353. text. TESetText doesn't affect the text drawn in the destination
  8354. rectangle, so call TEUpdate afterward if necessary. TESetText doesn't
  8355. dispose of any text currently in the edit record.
  8356. \ TEGetText
  8357. 8
  8358. Function TEGetText (hTE: TEHandle) : CharsHandle;
  8359.  
  8360.     TEGetText returns a handle to the text of the specified edit record.
  8361. The result is the same as the handle in the hText field of the edit
  8362. record, but has the CharsHandle data type, which is defined as:
  8363.  
  8364.        TYPE CharsHandle = ^CharsPtr;
  8365.             CharsPtr    = ^Chars;
  8366.         Chars       =PACKED ARRAY{0..3200] OF CHAR;
  8367.  
  8368.     You can get the length of the text from the teLength field of the
  8369. edit record.
  8370. \ TEIdle
  8371. 8
  8372. Procedure TEIdle (hTE: TEHandle);
  8373.  
  8374.     Call TEIdle repeatedly to make a blinking caret appear at the
  8375. insertion point (if any) in the text specified by hTE. (The caret
  8376. appears only when the window containing that text is active, of course.)
  8377. TextEdit observes a minimum blink interval:  No mater how often  you
  8378. call TEIdle, the time between blinks will never be less than the
  8379. minimum interval.
  8380.  
  8381. (note)
  8382.       You actually need to call TEIdle only when the window
  8383.       containing the text is active.
  8384. \ TEClick
  8385. 8
  8386. Procedure TEClick (pt: Point; extend: BOOLEAN; hTE: TEHandle);
  8387.  
  8388.     TEClick controls the placement and highlighting of the selection
  8389. range as determined by mouse events. Call TEClick whenever a mouse-down
  8390. event occurs in the view rectangle of the edit record specified by hTE,
  8391. and the window associated with that edit record is active. TEClick
  8392. keeps control until the mouse button is released. Pt is the mouse
  8393. location (in local coordinates) at the time the button was pressed,
  8394. obtainable from the event record.
  8395.  
  8396. (note)
  8397.       Use the QuickDraw procedure GlobalToLocal to convert the
  8398.       global coordinates of the mouse location given in the
  8399.       event record to the local coordinate system for pt.
  8400.  
  8401.     Pass TRUE for the extend parameter if the Event Manager indicates
  8402. that the Shift key was held down at the time of the click (to extend the
  8403. selection).
  8404.  
  8405.     TEClick unhighlights the old selection range unless the selection
  8406. range is being extended. If the mouse moves, meaning that a drag is
  8407. occurring, TEClick expands or shortens the selection range accordingly.
  8408. In the case of a double-click, the word under the cursor becomes the
  8409. selection range; dragging expands or shortens the selection a word at a
  8410. time.
  8411. \ TESetSelect
  8412. 8
  8413. Procedure TESetSelect (selStart,selEnd: LONGINT; hTE: TEHandle);
  8414.  
  8415.     TESetSelect sets the selection range to the text between selStart
  8416. and selEnd in the text specified by hTE. The old selection range is
  8417. unhighlighted, and the new one is highlighted. If selStart equals
  8418. selEnd, the selection range is an insertion point, and a caret is
  8419. displayed
  8420.  
  8421.     SelEnd and selStart can range from 0 to 32767. If selEnd is
  8422. anywhere beyond the last character of the text, the position just past
  8423. the last character is used.
  8424. \ TEActivate
  8425. 8
  8426. Procedure TEActivate (hTE: TEHandle);
  8427.  
  8428.     TEActivate highlights the selection range in the view rectangle of
  8429. the edit record specified by hTE. If the selection range is an
  8430. insertion point, it displays a caret there. This procedure should be
  8431. called every time the Toolbox Event Manager function GetNextEvent
  8432. reports that the window containing the edit record has become active.
  8433. \ TEDeactivate
  8434. 8
  8435. Procedure TEDeactivate (hTE: TEHandle);
  8436.  
  8437.     TEDeactivate unhighlights the selection range in the view rectangle
  8438. of the edit record specified by hTE. If the selection range is an
  8439. insertion point, it removes the caret. This procedure should be called
  8440. every time the Toolbox Event Manager function GetNextEvent reports that
  8441. the window containing the edit record has become inactive.
  8442. \ TEKey
  8443. 8
  8444. Procedure TEKey (key: CHAR; hTE: TEHandle);
  8445.  
  8446.     TEKey replaces the selection range in the text specified by hTE with
  8447. the character given by the key parameter, and leaves an insertion point
  8448. just past the inserted character. If the selection range is an
  8449. insertion point, TEKey just inserts the character there. If the key
  8450. parameter contains a Backspace character, the selection range or the
  8451. character immediately to the left of the insertion point is deleted.
  8452. TEKey redraws the text as necessary. Call TEKey every time the Toolbox
  8453. Event Manager function GetNextEvent reports a keyboard event that your
  8454. application decides should be handled by TextEdit.
  8455.  
  8456. (note)
  8457.       TEKey inserts every character passed in the key
  8458.       parameter, so it's up to your application to filter out
  8459.       all characters that aren't actual text (such as keys
  8460.       typed in conjuction with the Command key).
  8461. \ TECut
  8462. 8
  8463. Procedure TECut (hTE: TEHandle);
  8464.  
  8465.     TECut removes the selection range from the text specified by hTE and
  8466. places it in the TextEdit scrap. The text is redrawn as necessary.
  8467. Anything previously in the scrap is lost. (See Figure 6.)  If the
  8468. selection range is an insertion point, the scrap is emptied.
  8469. \ TECopy
  8470. 8
  8471. Procedure TECopy (hTE: TEHandle);
  8472.  
  8473.     TECopy copies the selection range from the text specified by hTE
  8474. into the TextEdit scrap. Anything previously in the scrap is deleted.
  8475. The selection range is not deleted. If the selection range is an
  8476. insertion point, the scrap is emptied.
  8477. \ TEPaste
  8478. 8
  8479. Procedure TEPaste (hTE: TEHandle);
  8480.  
  8481.     TEPaste replaces the selection range in the text specified by hTE
  8482. with the contents of the TextEdit scrap, and leaves an insertion point
  8483. just past the inserted text. (See Figure 7.)  The text is redrawn as
  8484. necessary. If the scrap is empty, the selection range is deleted. If
  8485. the selection range is an insertion point, TEPaste just inserts the
  8486. scrap there.
  8487. \ TEDelete
  8488. 8
  8489. Procedure TEDelete (hTE: TEHandle);
  8490.  
  8491.     TEDelete removes the selection range from the text specified by hTE,
  8492. and redraws the text as necessary. TEDelete is the same as TECut
  8493. (above) except that it doesn't transfer the selection range to the
  8494. scrap. If the selection range is an insertion point, nothing happens.
  8495. \ TEInsert
  8496. 8
  8497. Procedure TEInsert (text: Ptr; length: LONGINT; hTE: TEHandle);
  8498.  
  8499.     TEInsert takes the specified text and inserts it just before the
  8500. selection range into the text indicated by hTE, redrawing the text as
  8501. necessary. The text parameter points to the text to be inserted, and
  8502. the length parameter indicates the number of characters to be inserted.
  8503. TEInsert doesn't affect either the current  selection range or the
  8504. scrap.
  8505. \ TESetJust
  8506. 8
  8507. Procedure TESetJust (just: INTEGER, hTE: TEHandle);
  8508.  
  8509.     TESetJust sets the justification of the text specified by hTE to
  8510. just. (See"Justification" under "Edit Records".)  TextEdit provides
  8511. three predefined constants for setting justification:
  8512.  
  8513.         CONST: teJustLeft   = 0;
  8514.                teJustCenter = 1;
  8515.                teJustRight  = -1;
  8516.  
  8517.     By default, text is left-justified. If you change the
  8518. justification, call TEUpdate after TESetJust, to redraw the text with
  8519. the new justification.
  8520. \ TEUpdate
  8521. 8
  8522. Procedure TEUpdate (rUpdate: Rect; hTE: TEHandle);
  8523.  
  8524.     TEUpdate draws the text specified by hTE within the rectangle
  8525. specified by rUpdate. The rUpdate rectangle must be given in the
  8526. coordinates of the current grafPort. Call TEUpdate every time the
  8527. Tolbox Event Manager function GetNextEvent reports an update event for a
  8528. text editing window--after you call the Window Manager procedure
  8529. BeginUpdate, and before you call EndUpdate.
  8530.  
  8531. Normally you'll do the following when an update event occurs:
  8532.  
  8533.        BeginUpdate(myWindow);
  8534.        EraseRect(myWindow^.portRect);
  8535.        TEUpdate(myWindow^I.protRect,hTE);
  8536.        EndUpdate(myWindow)
  8537.  
  8538.     If you don't include the EraseRect call, the caret may sometimes
  8539. remain visible when the window is deactivated.
  8540. \ TextBox
  8541. 8
  8542. Procedure TextBox (text: Ptr; length: LONGINT; box: Rect; just:
  8543.             INTEGER);
  8544.  
  8545.     TextBox draws the specified text in the rectangle indicated by the
  8546. box parameter with justification just. (See "justification" under "Edit
  8547. Records".)  The text parameter points to the text, and the length
  8548. parameter indicates the number of characters to draw. The rectangle is
  8549. specified in local coordinates, that must be at least as wide as the
  8550. first character drawn (about 20 pixels is usually a good width).
  8551. TextBox does not create an edit record, nor can the text that it draws
  8552. be edited; it's used solely for drawing text. For example:
  8553.  
  8554.     str := 'String in a box';
  8555.     SetRect(r,100,100,200,200);
  8556.     TextBox(POINTER(ORD(@str)+1),LENGTH(str),r,teJustCenter);
  8557.     FrameRect(r)
  8558.  
  8559.     Because Pascal strings start with a length byte, you must advance
  8560. the pointer one position past the beginning of the string to point to
  8561. the start of the text.
  8562. \ TEScroll
  8563. 8
  8564. Procedure TEScroll (dh,dv: INTEGER; hTE: TEHandle);
  8565.  
  8566.     TEScroll scrolls the text within the view rectangle of the specified
  8567. edit record by the number of pixels specified in the dh and dv
  8568. parameters. The edit record is specified by the hTE parameter.
  8569. Positive dh and dv values move the text right and down, respectively,
  8570. and negative values move the text left and up. For example,
  8571.  
  8572.      TEScroll(0,-hTE^^.lineHeight,hTE)
  8573.  
  8574. scrolls the text up one line. Remember that you scroll text up when
  8575. the user clicks in the scroll arrow pointing down. The destination
  8576. rectangle is offset by the amount you scroll.
  8577.  
  8578. (note)
  8579.       To implement automatic scrolling, you store the address
  8580.       of a routine in the clikLoop field of the edit record, as
  8581.       described above under "The TERec Data Type".
  8582. \ TEFromScrap
  8583. 8
  8584. Function TEFromScrap : OSErr;
  8585.  
  8586.     TEFromScrap copies the desk scrap to the TextEdit scrap.
  8587. \ TEToScrap
  8588. 8
  8589. Function TEToScrap : OSErr;
  8590.  
  8591.     TEToScrap copies the TextEdit scrap to the desk scrap.
  8592.  
  8593. (warning)
  8594.          You must call the Scrap Manager function ZeroScrap to
  8595.      initialize the desk scrap or clear its previous contents
  8596.      before calling TEToScrap.
  8597. \ TEScrapHandle
  8598. 8
  8599. Function TEScrapHandle : Handle;
  8600.  
  8601.     TEScrapHandle returns a handle to the TExtEdit scrap.
  8602. \ TEGetScrapLen
  8603. 8
  8604. Function TEGetScrapLen : LONGINT;
  8605.  
  8606.     TEGetScrapLen returns the size of the TextEdit scrap in bytes.
  8607. \ TESetScrapLen
  8608. 8
  8609. Procedure TESetScrapLen (length: LONGINT);
  8610.  
  8611.     TESetScrapLen sets the size of the TextEdit scrap to the given
  8612. number of bytes.
  8613. \ TECalText
  8614. 8
  8615. Procedure TECalText (hTE: TEHandle);
  8616.  
  8617.     TECalText recalculates the beginnings of all lines of text in the
  8618. edit record specified by hTE, updating elements of the lineStarts array.
  8619. Call  TECalText if you've changed the destination rectangle, the hText
  8620. field, or any other field that affects the number of characters per line.
  8621.  
  8622. (note)
  8623.       There are two ways to specify text to be edited. The
  8624.       easiest method is to use TESetText, which takes an
  8625.       existing edit record, creates a copy of the specified
  8626.       text, and stores a handle to the copy in the edit record.
  8627.       You can instead directly change the hText field of the
  8628.       edit record, and then call TECalText to recalculate the
  8629.       lineStarts aray to match the new text. If you have a
  8630.       lot of text, you can use the latter method to save space.
  8631. \ TESelView
  8632. 8
  8633. Procedure TESelView (hTE: TEHandle);
  8634.  
  8635.     If automatic scrolling has been enabled (by a call to TEAutoView,
  8636. described below), TESelView makes sure that the selection range is
  8637. visible, scrolling it into the view rectangle if necessary.
  8638. If automatic scrolling is disabled, TESelView does nothing.
  8639.  
  8640. Note:  The top left of the insertion is scrolled into view; if text
  8641. is being displayed in a rectangle that’s not tall enough, automatic
  8642. scrolling could cause the text to jump up and down at times.
  8643. \TEPinScroll
  8644. 8
  8645. Procedure TEPinScroll (dh,dv: INTEGER; hTE: TEHandle);
  8646.  
  8647.     TEPinScroll is similar to TEScroll except that it stops scrolling
  8648. when the last line scrolls into the view rectangle.
  8649. \TEAutoView
  8650. 8
  8651. Procedure TEAutoView (auto: BOOLEAN; hTE: TEHandle);
  8652.  
  8653.     TEAutoView enables and disables automatic scrolling of text in the
  8654. edit record specified by hTe. If the auto parameter is FALSE,
  8655. automatic scrolling is disabled and calling TESelView has no effect.
  8656. \ InitDialogs
  8657. 9
  8658. Procedure InitDialogs (restartProc: ProcPtr);
  8659.  
  8660.     Call InitDialogs once before all other Dialog Manager routines, to
  8661. initialize the Dialog Manager.
  8662.  
  8663.   -It sets a pointer to a fail-safe procedure as specified by
  8664.    restartProc; this pointer will be accessed when a system error
  8665.    (such as running out of memory) occurs. RestartProc should point
  8666.    to a procedure that will restart the application after a system
  8667.    error. If no such procedure is desired, pass NIL as the parameter.
  8668.  
  8669.   -It installs the standard sound procedure.
  8670.  
  8671.   -It passes empty strings to ParamText.
  8672. \ ErrorSound
  8673. 9
  8674. Procedure ErrorSound (soundProc: ProcPtr);
  8675.  
  8676.     ErrorSound sets the sound procedure for dialogs and alerts to the
  8677. Procedure pointed to by soundProc; if you don't call ErrorSound, the
  8678. Dialog Manager uses the standard sound procedure. (For details, see
  8679. the "Alerts" section abouve.)  If you pass NIL for soundProc, there will
  8680. be no sound (or menu bar blinking) at all.
  8681. \ SetDAFont
  8682. 9
  8683. Procedure SetDAFont (fontNum: INTEGER);  [Pascal only]
  8684.  
  8685.     For subsequently created dialogs and alerts, SetDAFont sets the font
  8686. of the dialog or alert window's grafPort to the font having the
  8687. specified font number. If you don't call this procedure, the system
  8688. font is used. SetDAFont affects statText and editText items but not
  8689. titles of controls, which are always in the system font.
  8690. \ NewDialog
  8691. 9
  8692. Function NewDialog (dStorage: Ptr; boundsRect: Rect; title: Str255;
  8693.             visible: BOOLEAN; procID: INTEGER; behind: WindowPtr;
  8694.         goAwayFlag: BOOLEAN; refCon: LongInt; items: Handle) :
  8695.         DialogPtr;
  8696.  
  8697.     NewDialog creates a dialog as specified by its parameters and
  8698. returns a pointer to the new dialog. The first eight parameters
  8699. (dStorage through refCon) are pased to the Window Manager function
  8700. NewWindow, which creates the dialog window; the meanings of these
  8701. parameters are summarized below. The items parameter is a handle to the
  8702. dialog's item list. You can get the items handle by calling the
  8703. Resource Mangager to read the item list from the resource file into
  8704. memory (But make a DetachResource before!).
  8705.  
  8706. (note)
  8707.       Advanced programmers can create their own item lists in
  8708.       memory rather than have them read from a resource file.
  8709.       The exact format is given later under "Formats of
  8710.       Resources for Dialogs and Alerts".
  8711.  
  8712.     DStorage is analogous to the wStorage parameter of NewWindow; it's a
  8713. pointer to the storage to use for the dialog record. If you pass NIL
  8714. for dStorage, the dialog record will be allocated on the heap (which,
  8715. in the case of modeless dialogs, may cause the heap to become
  8716. fragmented).
  8717.  
  8718.     BoundsRect, a rectangle given in global coordinates, determines the
  8719. dialog window's size and location. It becomes the portRect of the
  8720. window's grafPort. Remember that the top coordinate of this rectangle
  8721. should be at least 25 points below the top of the screen for a modal
  8722. dialog, to allow for the menu bar and the border around the portRect,
  8723. and at least 40 points below the top of the screen for a modeless
  8724. dialog, to allow for the menu bar and the window's title bar.
  8725.  
  8726.     Title is the title of a modeless dialog box; pass the empty string
  8727. for modal dialogs.
  8728.  
  8729.     If the visible parameter is TRUE, the dialog window is drawn on the
  8730. screen. If it's FALSE, the window is initially invisible and may later
  8731. be shown with a call to the Window Manager procedure ShowWindow.
  8732.  
  8733. (note)
  8734.       NewDialog generates an update event for the entire window
  8735.       contents, so the items aren't drawn immediately, with the
  8736.       exception of controls. The Dialog Manager calls the
  8737.       Control Manager to draw controls, and the Control Manager
  8738.       draws them immediately rather than via the standard
  8739.       update mechanism. Because of this, the Dialog Manager
  8740.       calls the Window Manager procedure ValidRect for the
  8741.       enclosing rectangle of each control, so the controls
  8742.       won't be drawn twice. If you find that the other items
  8743.       aren't being drawn soon enough after the controls, try
  8744.       making the window invisible initially and then calling
  8745.       ShowWindow to show it.
  8746.  
  8747.     ProcID is the window definition ID, which leads to the window
  8748. definition function for this type of window. The window definition IDs
  8749. for the standard types of dialog window are dBoxProc for the modal type
  8750. and documentProc for the modeless type.
  8751.  
  8752.     The behind parameter specifies the window behind which the dialog
  8753. window is to be placed on the desktop. Pass POINTER(-1) to bring up
  8754. the dialog window in front of all other windows.
  8755.  
  8756.     GoAwayFlag applies to modeles dialog boxes; if it's TRUE, the dialog
  8757. window has a close box in its title bar when the window is active.
  8758.  
  8759.     RefCon is the dialog window's reference value, which the application
  8760. may store into and access for any purpose.
  8761.  
  8762.     NewDialog sets the font of the dialog window's grafPort to the
  8763. system font or, if you previously called SetDAFont, to the specified
  8764. font. It also sets the window class in the window record to dialogKind.
  8765. \ GetNewDialog
  8766. 9
  8767. Function GetNewDialog (dialogID: INTEGER; dStorage: Ptr; behind:
  8768.             WindowPtr) : DialogPtr;
  8769.  
  8770.     Like NewDialog (above), GetNewDialog creates a dialog as specified
  8771. by its parameters and returns a pointer to the new dialog. Instead of
  8772. having the parameters boundsRect, title, visible, procID, goAwayFlag,
  8773. and refCon, GetNewDialog has a single dialogID parameter, where
  8774. dialogID is the resource ID of a dialog template that supplies the same
  8775. information as those parameters. The dialog template also contains the
  8776. resource ID of the dialog's item list. After calling the Resource
  8777. Manager to read the item list into memory (if it's not already in
  8778. memory), GetNewDialog makes a copy of the item list and uses that copy;
  8779. thus you may have multiple independent dialogs whose items have the
  8780. same types, locations, and initial contents. The dStorage and behind
  8781. parameters of GetNewDialog have the same meaning as in NewDialog.
  8782.  
  8783.     The GetNewDialog routine will attempt to load a 'dctb' resource and returns a pointer to a color grafPort if the resource exists. If no 'dctb' resource is present, GetNewDialog returns a pointer to an old grafPort.
  8784.  
  8785.     The dialog color table is copied before it is passed to SetWinSize unless its ctSize field is equal to –1, indicating that the default window colors are to be used instead. The copy is made so that the color table resource can be purged without affecting the dialog.
  8786.  
  8787.     The color dialog item list resource is duplicated as well, so it can be purgeable.
  8788. \ CloseDialog
  8789. 9
  8790. Procedure CloseDialog (theDialog: DialogPtr);
  8791.  
  8792.     CloseDialog removes theDialog's window from the screen and deletes
  8793. it from the window list, just as when the Window Manager procedure
  8794. CloseWindow is called. It releases the memory occupied by the
  8795. following:
  8796.  
  8797.   -The data structures associated with the dialog window (such as the
  8798.    window's structure, content, and update regions).
  8799.  
  8800.   -All the items in the dialog (except for pictures and icons, which
  8801.    might be shared resources), and any data structures associated
  8802.    with them. For example, it would dispose of the region occupied
  8803.    by the thumb of a scroll bar, or a similar region for some other
  8804.    control in the dialog.
  8805.  
  8806.     CloseDialog does not dispose of the dialog record or the item list.
  8807. Figure 6 illustrates the effect of CloseDialog (and DisposDialog,
  8808. described below).
  8809.  
  8810.     Call CloseDialog when you're done with a dialog if you supplied
  8811. NewDialog or GetNewDialog with a pointer to the dialog storage (in the
  8812. dStorage parameter) when you created the dialog.
  8813.  
  8814. (note)
  8815.       Even if you didn't supply a pointer to the dialog
  8816.       storage, you may want to call CloseDialog if you created
  8817.       the dialog with NewDialog. You would call CloseDialog if
  8818.       you wanted to keep the item list around (since, unlike
  8819.       GetNewDialog, NewDialog does not use a copy of the item
  8820.       list).
  8821. \ DisposDialog
  8822. 9
  8823. Procedure DisposDialog (theDialog: DialogPtr);
  8824.  
  8825.     DisposDialog calls CloseDialog (above) and then releases the memory
  8826. occupied by the dialog's item list and dialog record. Call
  8827. DisposDialog when you're done with a dialog if you let the dialog
  8828. record be allocated on the heap when you created the dialog (by passing
  8829. NIL as the dStorage parameter to NewDialog or GetNewDialog).
  8830. \ CouldDialog
  8831. 9
  8832. Procedure CouldDialog (dialogID:  INTEGER);
  8833.  
  8834.     CouldDialog ensures that the dialog template having the given
  8835. resource ID is in memory and makes it unable to be purged. It does the
  8836. same for the dialog window's definition function, the dialog's item list
  8837. resource, and any item defined as resources. This is useful if the
  8838. dialog box may come up when the resource file isn't accessible, such as
  8839. during a disk copy.
  8840.  
  8841.     The CouldDialog procedure makes the dialog color table template unpurgeable (reading it into memory if it isn’t already there), if it exists. It does the same for the dialog’s color item list, if it has one.
  8842.  
  8843. Warning:  CouldDialog doesn’t load or make 'FONT' or 'FOND' resources indicated in the color item list unpurgeable.
  8844. \ FreeDialog
  8845. 9
  8846. Procedure FreeDialog (dialogID: INTEGER);
  8847.  
  8848.     Given the resource ID of a dialog template previously specified in a
  8849. call to CouldDialog (above), FreeDialog undoes the effect of
  8850. CouldDialog. It should be called when there's no longer a need to keep
  8851. the resources in memory.
  8852.  
  8853.     Given the resource ID of a dialog template previously specified in a call to CouldDialog, the FreeDialog routine undoes the effect of CouldDialog, by restoring the original purge state of the color table and color item list resources.
  8854. \ ModalDialog
  8855. 9
  8856. Procedure ModalDialog (filterProc: ProcPtr; VAR itemHit: INTEGER);
  8857.  
  8858.     Call ModalDialog after creating a modal dialog and bringing up its
  8859. window in the frontmost plane. ModalDialog repeatedly gets and handles
  8860. events in the dialog's window; after handling an event involving an
  8861. enabled dialog item, it returns with the item number in itemHit.
  8862. Normally you'll then do whatever is appropriate as a response to an
  8863. event in that item.
  8864.  
  8865.     ModalDialog gets each event by calling the Toolbox Event Manager
  8866. Function GetNextEvent. If the event is a mouse-down event outside the
  8867. content region of the dialog window, ModalDialog emits sound number 1
  8868. (which should be a single beep) and gets the next event; otherwise, it
  8869. filters and handles the event as described below.
  8870.  
  8871. (note)
  8872.       Once before getting each event, ModalDialog calls
  8873.       SystemTask, a Desk Manager procedure that needs to be
  8874.       called regularly if the application is to support the use
  8875.       of desk accessories.
  8876.  
  8877.     The filterProc parameter determines how events are filtered. If it's
  8878.  NIL, the standard filterProc function is executed; this causes
  8879.  ModalDialog to return 1 in itemHit if the Return key or Enter key is
  8880.  pressed. If filterProc isn't NIL, ModalDialog filters events by
  8881.  executing the function it points to. Your filterProc function should
  8882.  have three parameters and return a Boolean value. For example, this is
  8883.  how it would be declared if it were named MyFilter:
  8884.  
  8885.       FUNCTION MyFilter (theDialog: DialogPtr; VAR theEvent:
  8886.                          EventRecord; VAR itemHit: INTEGER ) : BOOLEAN;
  8887.  
  8888.     A function result of FALSE tells ModalDialog to go ahead and handle
  8889. the event, which either can be sent through unchanged or can be changed
  8890. to simulate a different event. A function result of TRUE tells
  8891. ModalDialog to return imediately rather than handle the event; in this
  8892. case, the filterProc function sets itemHit to the item number that
  8893. ModalDialog should return.
  8894.  
  8895. (note)
  8896.       ModalDialog calls GetNextEvent with a mask that excludes
  8897.       disk-inserted events. To receive disk-inserted events,
  8898.       your filterProc function can call GetNextEvent (or
  8899.       EventAvail) with a mask that accepts only that type of event.
  8900.  
  8901.     ModalDialog handles the evnets for which the filterProc function
  8902. returns FALSE as follows:
  8903.  
  8904.   -In response to an activate or update event for the dialog window,
  8905.    ModalDialog activates or updates the window.
  8906.  
  8907.   -If the mouse button is pressed in an editText item, ModalDialog
  8908.    responds to the mouse activity as appropriate (displaying an
  8909.    insertion point or selecting text). If a key-down event occurs
  8910.    and there's an editText item, text entry and editing are handled
  8911.    in the standard way for such items (except that if the Command key
  8912.    is down, ModalDialog responds as though it isn't). In either
  8913.    case, ModalDialog returns if the editText item is enabled or does
  8914.    nothing if it's disabled. If a key-down event occurs when there's
  8915.    no editText item, ModalDialog does nothing.
  8916.  
  8917.   -If the mouse button is pressed in a control, ModalDialog calls the
  8918.    Control Manager function TrackControl. If the mouse button is
  8919.    released inside the control and the control is enabled,
  8920.    ModalDialog returns; otherwise, it does nothing.
  8921.  
  8922.   -If the mouse button is pressed in any other enabled item in the
  8923.    dialog box, ModalDialog returns. If the mouse button is pressed
  8924.    in any other disabled item or in no item, or if any other event
  8925.    occurs, ModalDialog does nothing.
  8926. \ IsDialogEvent
  8927. 9
  8928. Function IsDialogEvent (theEvent: EventRecord) : BOOLEAN;
  8929.  
  8930.     If your application includes any modeless dialogs, call
  8931. IsDialogEvent after calling the Toolbox Event Manager function
  8932. GetNextEvent. Pass the current event in theEvent. IsDialogEvent
  8933. determines whether theEvent needs to be handled as part of a dialog. If
  8934. theEvent is an activate or update event for a dialog window, a
  8935. mouse-down event in the content region of an active dialog window, or
  8936. any other type of event when a dialog window is active, IsDialogEvent
  8937. returns TRUE; otherwise, it returns FALSE.
  8938.  
  8939.     When FALSE is returned, just handle the event yourself like any
  8940. other event that's not dialog-related. When TRUE is returned, you'll
  8941. generally end up passing the event to DialogSelect for it to handle (as
  8942. described below), but first you should do some additional checking:
  8943.  
  8944.    - DialogSelect doesn't handle keyboard equivalents for commands.
  8945.      Check whether the event is a key-down event with the Command key
  8946.      held down and, if so, carry out the command if it's one that
  8947.      applies when a dialog window is active. (If the command doesn't
  8948.      so apply, do nothing.)
  8949.  
  8950.   - In special cases, you may want to bypass DialogSelect or do some
  8951.     preprocessing before calling it. If so, check for those events
  8952.     and respond accordingly. You would need to do this, for example,
  8953.     if the dialog is to respond to disk-inserted events.
  8954.  
  8955.     For cases other than these, pass the event to DialogSelect for it to
  8956. handle.
  8957. \ DialogSelect
  8958. 9
  8959. Function DialogSelect (theEvent: EventRecord; VAR theDialog: DialogPtr;
  8960.             VAR itemHit: INTEGER) : BOOLEAN;
  8961.  
  8962.     You'll normally call DialogSelect after IsDialogEvent, passing in
  8963. theEvent an event that needs to be handled as part of a modeless
  8964. dialog. DialogSelect handles the event as described below. If the
  8965. event involves an enabled dialog item, DialogSelect returns a function
  8966. result of TRUE with the dialog pointer in theDialog and the item number
  8967. in itemHit; otherwise, it returns FALSE with theeDialog and itemHit
  8968. undefined. Normally when DialogSelect returns TRUE, you'll do whatever
  8969. is appropriate as a response to the event, and when it returns FALSE
  8970. you'll do nothing.
  8971.  
  8972.     If the event is an activate or update event for a dialog window,
  8973. DialogSelect activates or updates the window ane returns FALSE.
  8974.  
  8975.     If the event is a mouse-down event in an editText item, DialogSelect
  8976. responds as appropriate (displaying an insertion point or selecting
  8977. text). If it's a key-down event and there's an editText item, text
  8978. entry and editing are handled in the standard way. In either case,
  8979. DialogSelect returns TRUE if the editText item is enabled or FALSE if
  8980. it's disabled. If a key-down event is passed when there's no editText
  8981. item, DialogSelect returns FALSE.
  8982.  
  8983. (note)
  8984.       For a key-down event, DialogSelect doesn't check to see
  8985.       whether the Command key is held down; to handle keyboard
  8986.       equivalents of commands, you have to check for them
  8987.       before calling DialogSelect. Similarly, to treat a typed
  8988.       character in a special way (such as ignore it, or make it
  8989.       have the same effect as another character or as clicking
  8990.       a button), you need to check for a key-down event with
  8991.       that character before calling DialogSelect.
  8992.  
  8993.     If the event is a mouse-down event in a control, DialogSelect calls
  8994. the Control Manager function TrackControl. If the mouse button is
  8995. released inside the control and the control is enabled, DialogSelect
  8996. returns TRUE; otherwise, it returns FALSE.
  8997.  
  8998.     If the event is a mouse-down event in any other enabled item,
  8999. DialogSelect returns TRUE. If it's  a mouse-down event in any other
  9000. disabled item or in no item, or if it's any other event, DialogSelect
  9001. returns FALSE.
  9002. \ DlgCut
  9003. 9
  9004. Procedure DlgCut (theDialog: DialogPtr);   [Pascal only]
  9005.  
  9006.     DlgCut checks whether theDialog has any editText items and, if so,
  9007. applies the textEdit procedure TECut to the currently selected editText
  9008. item. (If the dialog record's editField is 0 or greater, DlgCut passes
  9009. the contents of the textH field to TECut.)  You can call DlgCut to
  9010. handle the editing command Cut when a modeless dialog window is active.
  9011. \ DlgCopy
  9012. 9
  9013. Procedure DlgCopy (theDialog: DialogPtr);   [Pascal only]
  9014.  
  9015.     DlgCopy is the same as DlgCut (above) except that it calls TECopy,
  9016. for handling the Copy command.
  9017. \ DlgPaste
  9018. 9
  9019. Procedure DlgPaste (theDialog: DialogPtr);   [Pascal only]
  9020.  
  9021.     DlgPaste is the same as DlgCut (above) except that it calls TEPaste,
  9022. for handling the Paste command.
  9023. \ DlgDelete
  9024. 9
  9025. Procedure DlgDelete (theDialog: DialogPtr);   [Pascal only]
  9026.  
  9027.     DlgDelete is the same as DlgCut (above) except that it calls
  9028. TEDelete, for handling the Clear command.
  9029. \ DrawDialog
  9030. 9
  9031. Procedure DrawDialog (theDialog: DialogPtr);
  9032.  
  9033.     DrawDialog draws the contents of the given dialog box. Since
  9034. DialogSelect and ModallDialog handle dialog window updating, this
  9035. Procedure is useful only in unusual situations. You would call it, for
  9036. example, to display a dialog box that doesn't require any response but
  9037. merely tells the user what's going on during a time-consuming process.
  9038. \ Alert
  9039. 9
  9040. Function Alert (alertID: INTEGER; filterProc: ProcPtr) : INTEGER;
  9041.  
  9042.     This function invokes the alert defined by the alert template that
  9043. has the given resource ID. It calls the currnet sound procedure, if
  9044. any,l passing it the sound number specified in the alert template for
  9045. this stage of the alert. If no alert box is to be drawn at this stage,
  9046. Alert returns a function result of -1; otherwise, it creates and
  9047. displays the alert window for this alert and draws the alert box.
  9048.  
  9049.     The Alert function looks for a resource of type 'actb' with the same ID as the alert. The alert color table is copied before it is passed to SetWinSize unless its ctSize field is equal to –1, indicating that the default window colors are to be used instead. The copy is made so that the color table resource can be purged without affecting the alert.
  9050.  
  9051.     The color dialog item list resource is duplicated as well, so it can be purgeable.
  9052.  
  9053. (note)
  9054.       It creates the alert window by calling NewDialog, and
  9055.       does the rest of its processing by calling ModalDialog.
  9056.  
  9057.     Alert repeatedly gets and handles events in the alert window until
  9058. an enabled item is clicked, at which time it returns the item number.
  9059. Normally you'll then do whatever is appropriate in response to a click
  9060. of that item.
  9061.  
  9062.     Alert gets each event by calling theToolbox Event Manager function
  9063. GetNextEvent. If the event is a mouse-down event outside the content
  9064. region of the alert window, Alert emits sound number 1 (which should be
  9065. a single beep) and gets the next event; otherwise, it filters and
  9066. handles the event as describe below.
  9067.  
  9068.     The filterProc parameter has the same meaning as in ModalDialog (see
  9069. above). If it's NIL, the standard filterProc function is executed,
  9070. which makes the Return key or the Enter key have the same effect as
  9071. clicking the default button. If you specify your own filterProc
  9072. Function and want to retain this feature, you must include it in your
  9073. Function. You can find out what the current default button is by
  9074. looking at the aDefItem field of the dialog record for the alert (via
  9075. the dialog pointer passed to the function).
  9076.  
  9077.     Alert handles the events for which the filterProc function returns
  9078. FALSE as follows:
  9079.  
  9080.  
  9081.   - If the mouse button is pressed in a control, Alert calls the
  9082.     Control Manager procedure TrackControl. If the mouse buton is
  9083.     released inside the control and the control is enabled, Alert
  9084.     returns; otherwise, it does nothing.
  9085.  
  9086.   - If the mouse button is pressed in any other enabled item, Alert
  9087.     simply returns. If it's pressed in any other disabled item or in
  9088.     no item, or if any other event occurs, Alert does nothing.
  9089.  
  9090.     Before returning to the application with the item number, Alert
  9091. removes the alert box from the screen. (It disposes of the alert window
  9092. and its associated data structures, the item list, and the items.)
  9093.  
  9094. (note)
  9095.        The Alert function's removal of the alert box would not
  9096.        be the desired result if the user clicked a check box or
  9097.        radio button; however, normally alerts contain only
  9098.        static text, icons, pictures, and buttons that are
  9099.        supposed to make the alert box go away. If your alert
  9100.        contains other items besides these, consider whether it
  9101.        might be more appropriate as a dialog.
  9102.  
  9103. \ StopAlert
  9104. 9
  9105. Function StopAlert (alertID: INTEGER; filterProc: ProcPtr) : INTEGER;
  9106.  
  9107.     StopAlert is the same as the Alert function (above) except that
  9108. before drawing the items of the alert in the alert box, it draws the
  9109. Stop icon in the top left corner of the box (within the rectangle
  9110. (10,20,42,52)). The Stop icon has the following resource ID:
  9111.  
  9112.        CONST stopIcon = 0;
  9113.  
  9114.     The call StopAlert look for a resource of type 'actb' with the same ID as the alert.
  9115.  
  9116.     If the application's resource file doesn't include an icon with that
  9117. ID number, the Dialog Manager uses the standart Stop icon in the system
  9118. resource file (see Figure 7).
  9119. \ NoteAlert
  9120. 9
  9121. Function NoteAlert (alertID: INTEGER; filterProcf: ProcPtr) : INTEGER;
  9122.  
  9123.     NoteAlert is like StopAlert except that it draws the Note icon,
  9124. which has the following resource ID:
  9125.  
  9126.        CONST noteIcon = 1;
  9127.  
  9128.     The call NoteAlert look for a resource of type 'actb' with the same ID as the alert.
  9129. \ CautionAlert
  9130. 9
  9131. Function CautionAlert (alertID: INTEGER; filterProc: ProcPtr) :
  9132.            INTEGER;
  9133.  
  9134.     CautionAlert is like StopAlert except that it draws the Caution
  9135. icon, which has the following resource ID:
  9136.  
  9137.        CONST ctnIcon = 2;
  9138.  
  9139.     The call CautionAlert look for a resource of type 'actb' with the same ID as the alert.
  9140. \ CouldAlert
  9141. 9
  9142. Procedure CouldAlert (alertID: INTEGER);
  9143.  
  9144.     CouldAlert ensures that the alert template having the given resource
  9145. ID is in memory and makes it unable to be purged. It does the same for
  9146. the alert window's definition function, the alert's item list resource,
  9147. and any items defined as resources. This is useful if the alert may
  9148. occur when the resource file isn't accessible, such as during a disk
  9149. copy.
  9150.  
  9151.     The CouldAlert routine makes the alert color table template unpurgeable (reading it into memory if it isn’t already there), if it exists. It does the same for the alert’s color item list, if it has one.
  9152.  
  9153. Warning:  Like CouldDialog, CouldAlert doesn’t load or make 'FONT' or 'FOND' resources indicated in the color item list unpurgeable.
  9154. \ FreeAlert
  9155. 9
  9156. Procedure FreeAlert (alertID: INTEGER);
  9157.  
  9158.     Given the resource ID of an alert template previously specified in a
  9159. call to CouldAlert (above), FreeAlert undoes the effect of CouldAlert.
  9160. It should be called when there's no longer a need to keep the resources
  9161. in memory.
  9162.  
  9163.     Given the resource ID of an alert template previously specified in a call to CouldAlert, the FreeAlert routine undoes the effect of CouldAlert, by restoring the original purge state of the color table and color item list resources.
  9164. \ ParamText
  9165. 9
  9166. Procedure ParamText (param0,param1,param2,param3: Str255);
  9167.  
  9168.     ParamText provides a means of substituting text in statText items:
  9169. param0 through param3 will replace the special strings '^0' through
  9170. '^I3' in all statText items in all subsequent dialog or alert boxes.
  9171. Pass empty strings for parameters not used.
  9172.  
  9173.     For example, if the text is defined as 'Cannot open document ^0' and
  9174. docName is a string variable containg a document name that the user
  9175. typed, you can call ParamText(docName, '','','').
  9176.  
  9177. (warning)
  9178.          All strings that will need to be translated to foreign
  9179.         languages should be stored in resource files.
  9180.  
  9181.  
  9182.  
  9183. \ GetDItem
  9184. 9
  9185. Procedure GetDItem (theDialog: DialogPtr; itemNo: INTEGER; VAR itemtype:
  9186.                     INTEGER; VAR item: Handle; VAR box: Rect);
  9187.  
  9188.     GetDItem returns in its VAR parameters the following information
  9189. about the item numbered itemNo in the given dialog's item list: in the
  9190. itemtype parameter, the item type; in the item parameter, a handle to the
  9191. item (or, for item type userItem, the procedure pointer); and in the box
  9192. parameter, the display rectangle for the item.
  9193.  
  9194.     Suppose, for example, that you want to change the title of a control
  9195. in a dialog box. You can get the item handle with GetDItem, convert it
  9196. to type ControlHandle, and call the Control Manager procedure SetCTitle
  9197. to change the title. Similarly, to move the control or change its size,
  9198. you would call MoveControl or SizeControl.
  9199.  
  9200. (note)
  9201.       To access the text of a statText or editText item, pass
  9202.       the handle returned by GetDItem to GetIText or SetIText
  9203.       (see below).
  9204. \ SetDItem
  9205. 9
  9206. Procedure SetDItem (theDialog: DialogPtr; itemNo: INTEGER; ItemType:
  9207.             INTEGER; item: Handle; box: rect);
  9208.  
  9209.     SetDItem sets the item numbered itemNo in the given dialog's item
  9210. list, as specified by the parameters (without drawing the item). The
  9211. type parameter is the item type; the item parameter is a handle to the
  9212. item (or, for item type userItem, the procedure pointer); and the box
  9213. parameter is the display rectangle for the item.
  9214.  
  9215.     Consider, for example, how to install an item of type userItem in a
  9216. dialog:  In the item list in the resource file, define an item in which
  9217. the type is set to userItem and the display rectangle to (0,0,0,0).
  9218. Specify that the dialog window be invisible (in either the dialog
  9219. template or the NewDialog call). After creating the dialog, convert
  9220. the item's procedure pointer to type Handle; then call SetDItem,
  9221. passing that handle and the display rectangle for the item. Finally,
  9222. call the Window Manager procedure ShowWindow to display the dialog
  9223. window.
  9224.  
  9225. (note)
  9226.       Do not use SetDItem to change the text of a statText or
  9227.       editText item or to change or move a control. See the
  9228.       description of GetDItem above for more information.
  9229. \ GetIText
  9230. 9
  9231. Procedure GetIText (item: Handle; VAR text: str255);
  9232.  
  9233.     Given a handle to a statText or editText item in a dialog box, as
  9234. returned by GetDItem, GetIText returns the text of the item in the text
  9235. parameter.
  9236. \ SetIText
  9237. 9
  9238. Procedure SetIText (item: Handle; text: Str255);
  9239.  
  9240.     Given a handle to a statText or editText item in a dialog box, as
  9241. returned by GetDItem, SetIText sets the text of the item to the
  9242. specified text and draws the item. For example, suppose the exact
  9243. content of a dialog's text item cannot be determined until the
  9244. application is running, but the display rectangle is defined in the
  9245. resource file:  Call GetDItem to get a handle to the item, and call
  9246. SetIText with the desired text.
  9247. \ SelIText
  9248. 9
  9249. Procedure SelIText (theDialog: DIalogPtr; itemNo: INTEGER;
  9250.            strtSel,endSel: INTEGER);
  9251.  
  9252.     Given a pointer to a dialog and the item number of an editText item
  9253. in the dialog box, SelIText does the following:
  9254.  
  9255.    - If the item contains text, SelIText sets the selection range to
  9256.      extend from character position strtSel up to but not including
  9257.      character position endSel. The selection range is inverted unless
  9258.      strtSel equals endSel, in which case a blinking vertical bar is
  9259.      displayed to indicate an insertion point at that position.
  9260.  
  9261.    - If the item doesn't contain text, SelIText simply displays the
  9262.      insertion point.
  9263.  
  9264.     For example, if the user makes an unacceptable entry in the editText
  9265. item, the application can put up an alert box reporting the problem and
  9266. then select the entire text of the item so it can be replaced by a new
  9267. entry. (Without this procedure, the user would have to select the item
  9268. before making the new entry.)
  9269.  
  9270. (note)
  9271.       You can select the entire text by specifying 0 for
  9272.       strtSel and a very large number for endSel. For details
  9273.       about selection range and character position, see the
  9274.       TextEdit manual.
  9275. \ GetAlrtStage
  9276. 9
  9277. Function GetAlrtStage : INTEGER;   [Pascal only]
  9278.  
  9279.     GetAlrtStage returns the stage of the last occurrence of an alert,
  9280. as a number from 0 to 3.
  9281. \ ResetAlrtStage
  9282. 9
  9283. Procedure ResetAlrtStage;   [Pascal only]
  9284.  
  9285.     ResetAlrtStage resets the stage of the last occurrence of an alert
  9286. so that the next occurrenct of the same alert will be treatd as its
  9287. first stage. This is useful, for example, when you've used ParamText
  9288. to change the text of an alert such that from the user's point of view
  9289. it's a different alert.
  9290. \ HideDItem
  9291. 9
  9292. Procedure HideDItem (theDialog: DialogPtr; itemNo: INTEGER);
  9293.  
  9294.     HideDItem hides the item numbered itemNo in the given dialog’s item
  9295. list by giving the item a display rectangle that’s off the screen.
  9296. (Specifically, if the left coordinate of the item’s display rectangle
  9297. is less than 8192, ShowDItem adds 16384 to both the left and right
  9298. coordinates the rectangle.)  If the item is already hidden (that is,
  9299. if the left coordinate is greater than 8192), HideDItem does nothing.
  9300.  
  9301.     HideDItem calls the EraseRect procedure on the item’s enclosing
  9302. rectangle and adds the rectangle that contained the item (not
  9303. necessarily the item’s display rectangle) to the update region.
  9304. If the specified item is an active editText item, the item is first
  9305. deactivated (by calling TEDeactivate).
  9306.  
  9307. Note:  If you have items that are close to each other, be aware that
  9308.        the Dialog Manager draws outside of the enclosing rectangle by 3
  9309.        pixels for editText items and by 4 pixels for a default button.
  9310.  
  9311.     An item that’s been hidden by HideDItem can be redisplayed by the
  9312. ShowDItem procedure.
  9313.  
  9314. Note:  To create a hidden item in a dialog item list, simply add
  9315.        16384 to the left and right coordinates of the display rectangle.
  9316. \ ShowDItem
  9317. 9
  9318. Procedure ShowDItem (theDialog: DialogPtr; itemNo: INTEGER);
  9319.  
  9320.     ShowDItem redisplays the item numbered itemNo, previously hidden by
  9321. HideDItem, by giving the item the display rectangle it had prior to
  9322. the HideDItem call. (Specifically, if the left coordinate of the
  9323. item’s display rectangle is greater than 8192, ShowDItem subtracts
  9324. 16384 from both the left and right coordinates the rectangle.)
  9325. If the item is already visible (that is, if the left coordinate is
  9326. less than 8192), ShowDItem does nothing.
  9327.  
  9328.     ShowDItem adds the rectangle that contained the item (not
  9329. necessarily the item’s display rectangle) to the update region so
  9330. that it will be drawn. If the item becomes the only editText item,
  9331. ShowDItem activates it (by calling TEActivate).
  9332. \FindDItem
  9333. 9
  9334. Function FindDItem (theDialog: DialogPtr; thePt: Point) : INTEGER;
  9335.  
  9336.     FindDItem returns the item number of the item containing the point
  9337. specified, in local coordinates, by thePt. If the point doesn’t lie
  9338. within the item’s rectangle, FindDItem returns –1.  If there are
  9339. overlapping items, it returns the item number of the first item in
  9340. the list containing the point. FindDItem is useful for changing the
  9341. cursor when it’s over a particular item.
  9342.  
  9343. Note:  FindDItem will return the item number of disabled items as well.
  9344. \UpdtDialog
  9345. 9
  9346. Procedure UpdtDialog (theDialog: DialogPtr; updateRgn: RgnHandle);
  9347.  
  9348.     UpdtDialog is a faster version of the DrawDialog procedure.
  9349. Instead of drawing the entire contents of the given dialog box,
  9350. UpdtDialog draws only the items that are in a specified update region.
  9351. UpdtDialog is called in response to an update event, and is usually
  9352. bracketed by calls to the Window Manager procedures BeginUpdate and
  9353. EndUpdate. UpdateRgn should be set to the visRgn of theWindow’s port.
  9354. (For more details, see the BeginUpdate procedure in chapter 9 of
  9355. Volume I.)
  9356. \ OpenDeskAcc
  9357. 10
  9358. Function OpenDeskAcc (theAcc: Str255) : INTEGER;
  9359.  
  9360.     OpenDeskAcc opens the desk accessory having the given name and
  9361. displays its window (if any) as the active window. The name is the
  9362. accessory's resource name, which you get from the Apple menu by calling
  9363. the Menu Manager procedure GetItem. OpenDeskAcc calls the Resource
  9364. Manager to read the desk accessory from the resource file.
  9365.  
  9366.     You should ignore the value returned by OpenDeskAcc. If the desk
  9367. accessory is successfully opened, the function result is its driver
  9368. reference number; as described under CloseDeskAcc below, you don't need
  9369. this number to close the accessory. If the desk accessory can't be
  9370. opened, the function result is undefined; the accessory will have taken
  9371. care of informing the user of the problem (such as memory full) and not
  9372. displaying itself.
  9373.  
  9374. (warning)
  9375.          It may occasionally happen that the current grafPort will
  9376.          be the desk accessory's port upon return from
  9377.          OpenDeskAcc. To be safe, you should bracket your call to
  9378.          OpenDeskAcc with calls to the QuickDraw procedures
  9379.          GetPort and SetPort, to save and restore the current
  9380.          port.
  9381.  
  9382.     Before you open a desk accessory it's a good idea to determine
  9383. whether there's enough memory available. Here's an example of how to do
  9384. that:
  9385.  
  9386.         SetResLoad(FALSE);
  9387.         myResHandle := GetNamedResource('DRVR', theAcc);
  9388.         size := SizeResource(myResHandle);
  9389.         myHandle := NewHanddle(size + 3072);
  9390.         IF myHandle = NIL
  9391.           THEN {put up an alert indicating there's not enough memory}
  9392.           ELSE OpenDeskAcc(theAcc)
  9393.  
  9394.     The extra 3K bytes in the argument to the Memory Manager's NewHandle
  9395. Function is an average amount of heap space used by desk accessories
  9396. while they're running.
  9397. \ CloseDeskAcc
  9398. 10
  9399. Procedure CloseDeskAcc (refNum: INTEGER);
  9400.  
  9401.     When a system window is active and the user choses Close from the
  9402. File menu, call CloseDeskAcc to close the desk accessory. RefNum is the
  9403. driver reference number for the desk accessory, which you get from the
  9404. windowKind field of its window.
  9405.  
  9406.     The Desk Manager automatically closes a desk accessory if the user
  9407. clicks its close box. Also, since the application heap is released
  9408. when the application terminates, every desk accessory goes away at that
  9409. time.
  9410. \ SystemClick
  9411. 10
  9412. Procedure SystemClick (theEvent: EventRecord; theWindow: WindowPtr);
  9413.  
  9414.     When a mouse-down event occurs and the Window Manager function
  9415. FindWindow reports that the mouse button was pressed in a system
  9416. window, the application should call SystemClick with the event record
  9417. and the window pointer. If the given window belongs to a desk
  9418. accessory, SystemClick sees that the event gets handled properly.
  9419.  
  9420.     SystemClick determines which part of the desk accessory's window the
  9421. mouse button was pressed in, and responds accordingly (similar to the
  9422. way your application responds to mouse activities in its own windows).
  9423.  
  9424.   - If the mouse button was pressed in the content region and the
  9425.     window and the window was active, SystemClick sends the mouse-down
  9426.     event to the desk accessory, which proceses it as appropriate.
  9427.  
  9428.   - If the mouse button was pressed in the content region and the
  9429.     window was inactive, SystemClick makes it the active window.
  9430.  
  9431.   - If the mouse button was pressed in the drag region, SystemClick
  9432.     calls the Window Manager procedure DragWindow to pull an outline
  9433.     of the window across the screen and move the window to a new
  9434.     location. If the window was inactive, DragWindow also makes it
  9435.     the active window (unless the Command key was pressed along with
  9436.     the mouse button).
  9437.  
  9438.   - If the mouse button was pressed in the go-away region, SystemClick
  9439.     calls the Window Manager function TrackGoAway to determine whether
  9440.     the mouse is still inside the go-away region when the click is
  9441.     completed:  if so, it tells the desk accessory to close itself
  9442.     otherwise, it does nothing.
  9443. \ SystemEdit
  9444. 10
  9445. Function SystemEdit (editCmd: INTEGER) : BOOLEAN;
  9446.  
  9447.     Call SystemEdit when there's a mouse-down event in the menu bar and
  9448. the user choses one of the five standard editing commands from the Edit
  9449. menu. Pass one of the following as the value of the editCmd parameter:
  9450.  
  9451.        EditCmd          Editing command
  9452.        0                Undo
  9453.        2                Cut
  9454.        3                Copy
  9455.        4                Paste
  9456.        5                Clear
  9457.  
  9458.  
  9459.     If your Edit menu contains these five commands in the standard
  9460. arrangement (the order listed above, with a gray line separating Undo
  9461. and Cut), you can simply call
  9462.  
  9463.      SystemEdit(menuItem - 1)
  9464.  
  9465.     If the active window dewsn't belong to a desk accessory, SystemEdit
  9466. returns FALSE; the application should then process the editing comand
  9467. as usual. If the active window dews belong to a desk accessory,
  9468. SystemEdit asks that accessory to process the command and returns TRUE;
  9469. in this case, the application should ignore the command.
  9470.  
  9471. (note)
  9472.       It's up to the application to make sure desk accessories
  9473.       get their editing comands that are chosen from the Edit
  9474.       menu. In particular, make sure your application hasn't
  9475.       disabled the Edit menu or any of the five standard
  9476.       commands when a desk accessory is activated.
  9477. \ SystemTask
  9478. 10
  9479. Procedure SystemTask;
  9480.  
  9481.     For each open desk accessory, SystemTask causes the accessory to
  9482. perform the periodic action defined for it, if any such action has been
  9483. defined and if the proper time period has passed since the action was
  9484. last performed. For example, a clock accessory can be deifined such
  9485. that the second hand is to move once every second; the periodic action
  9486. for the accessory will be to move the second hand to the next position,
  9487. and SystemTask will alert the accessory every second to perform that
  9488. action.
  9489.  
  9490.     You should call SystemTask as often as possible, usually once every
  9491. time through your main event loop. Call it more than once if your
  9492. applicaition dies an unusually large amount of processing each time
  9493. through the loopk.
  9494.  
  9495. (note)
  9496.       SystemTask should be called at least every sixtieth of a
  9497.       second.
  9498.  
  9499.  
  9500.  
  9501. \ SystemEvent
  9502. 10
  9503. Function SystemEvent (theEvent: EventRecord) : BOOLEAN;
  9504.  
  9505.     SystemEvent is called only by the Toolbox Event Manager function
  9506. GetNextEvent when it receives an event, to determine whether the event
  9507. should be handled by the application or by the system. If the given
  9508. event should be handled by the application, SystemEvent returns FALSE;
  9509. otherwise, it calls the appropriate system code to handle the event and
  9510. returns TRUE.
  9511.  
  9512.     In the case of a null, abort, or mouse-down event, SystemEvent does
  9513. nothing but return FALSE. Notice that it responds this way to a mouse-
  9514. down event even though the event may in fact have occurred in a system
  9515. window (and therefore may have to be handled by the system). The
  9516. reason for this is that the check for exactly where the event occurred
  9517. (via the Window Manager function FindWindow) is made later by the
  9518. applicaiton and so would be made twice if SystemEvent were also to do
  9519. it. To avoid this duplication, SystemEvent passes the event on to the
  9520. application and lets it make the sole call to FindWindow. Should
  9521. FindWindow reveal that the mouse-down event did occur in a system
  9522. window, the application can then call SystemClick, as described above,
  9523. to get the system to handle it.
  9524.  
  9525.     If the given event is a mouse-up or keyboard event, SystemEvent
  9526. checks whether the active window belongs to a desk accessory and whether
  9527. that accessory can handle this type of event. If so, it sends the event
  9528. to the desk accessory and returns TRUE; otherwise, it returns FALSE.
  9529.  
  9530. (note)
  9531.       It's unlikely that a desk accessory would not be set up
  9532.       to handle activate and update events.
  9533.  
  9534.     Finally, if the given event is a disk-inserted event, SylstemEvent
  9535. does some low-level processing (by calling the File Manager function
  9536. McountVol) but passes the event on to the application by returning
  9537. FALSE, in case the application wants to do further processing.
  9538. \ SystemMenu
  9539. 10
  9540. Procedure SystemMenu (menuResult: LONGINT);
  9541.  
  9542.     SystemMenu is called only by the Menu Manager functions MenuSelect
  9543. and MenuKey, when an item in a menu belonging to a desk accessory has
  9544. been chosen. The menuResult parameter has the same format as the value
  9545. returned by MenuSelect and MenuKey:  the menu ID in the high-order word
  9546. and the menu item number in the low-order word. (The menu ID will be
  9547. negative.)  SystemMenu directs the desk accessory to perform the
  9548. appropriate action for the given menu item.
  9549. \ InfoScrap
  9550. 11
  9551. Function InfoScrap : PScrapStuff;
  9552.  
  9553.     dInfoScrap returns a pointer to information about the desk scrap.
  9554. The PScrapStuff data type is defined as follows:
  9555.  
  9556. TYPE PScrapStuff = ^ScrapStuff;
  9557.      ScrapStuff = RECORD
  9558.             scrapSize:    LONGINT;   {size of desk scrap}
  9559.             scrapHandle:  Handle;    {handle to desk scrap}
  9560.             scrapCount:   INTEGER;   {count changed by ZeroScrap}
  9561.             scratState:   INTEGER;   {tells where desk scrap is}
  9562.             scrapName:    StringPtr  {scrap file name}
  9563.           END;
  9564.  
  9565.  
  9566.     ScrapSize is the size of the desk scrap in bytes. ScrapHandle is a
  9567. handle to the scrap if it's in memory, or NIL if not.
  9568.  
  9569.     ScrapCount is a count that changes every time ZeroScrap is called,
  9570. and is useful for testing whether the contents of the desk scrap have
  9571. changed during the use of a desk accessory. ScrapState is positive if
  9572. the desk scrap is in memory, 0 if it's on the disk, or negative if it
  9573. hasn't been initialized by ZeroScrap.
  9574.  
  9575. (note)
  9576.        ScrapState is actually 0 if the scrap should be on the
  9577.        disk; for instance, if the user deletes the Clipboard
  9578.        file and then cuts something, the scrap is really in
  9579.        memory, but ScrapState will be 0.
  9580.  
  9581.  
  9582.     ScrapName is a pointer to the name of the scrap file, usually
  9583. "Clipboard File".
  9584.  
  9585. (note)
  9586.       InfoScrap assumes that the scrap file has a version
  9587.       number of 0 and is on the default volume. (Version
  9588.       numbers and volumes are described in the File Manager
  9589.       manual.)
  9590. \ UnloadScrap
  9591. 11
  9592. Function UnloadScrap : LONGINT;
  9593.  
  9594.     UnloadScrap writes the desk scrap from memory to the scrap file, and
  9595. relaeses the memory it occupied. If the desk scrap is already on the
  9596. disk, UnloadScrap does nothing. If no error occurs, UnloadScrap
  9597. returns the result code noErr; otherwise, it returns and Operating
  9598. System result code indicating an error.
  9599. \ LoadScrap
  9600. 11
  9601. Function LoadScrap : LONGINT;
  9602.  
  9603.     LoadScrap reads the desk scrap from the scrap file into memory. If
  9604. the desk scrap is already in memory, it does nothing. If no error
  9605. occurs, LoadScrap returns the result code noErr; otherwise, it returns
  9606. an Operating System result code indicating an error.
  9607. \ GetScrap
  9608. 11
  9609. Function GetScrap (hDest: Handle; theType: ResType; VAR offset:
  9610.                     LONGINT) : LONGINT;
  9611.  
  9612.     Given an existing handle in hDest, GetScrap reads the data of type
  9613. theType from the desk scrap (whether in memory or on the disk), makes a
  9614. copy of it in memory, and sets hDest to be a handle to the copy.
  9615. Usually you'll pass in hDest a handle to a minimum-size block; GetScrap
  9616. will resize the block and copy the scrap into it. If you pass NIL in
  9617. hDest, GetScrap will not read in the data. This is usefull if you want
  9618. to be sure the data is there before allocating space for its handle, or
  9619. if you just want to know the size of the data.
  9620.  
  9621.     In the offset parameter, GetScrap returns the location of the data
  9622. as an offset (in bytes) from the beginning of the desk scrap. If no
  9623. error occurs, the function result is the length of the data in bytes;
  9624. otherwise, it's either an appropriate Operatiing System result code
  9625. (which will be negative) or the following Scrap Manager result code:
  9626.  
  9627.         CONST noTypeErr = -102;   {no data of the requested type}
  9628.  
  9629. For example, given the declaration
  9630.  
  9631.         VAR pHndl: Handle;      {handle for 'PICT' type}
  9632.         tHndl: Handle;          {handle for 'TEXT' type}
  9633.         length: LONGINT;
  9634.         offset: LONGINT;
  9635.  
  9636. you can make the following calls:
  9637.  
  9638.         pHndl := NewHandle(0);
  9639.         length := GetScrap(pHandl,'PICT',offset);
  9640.         IF length < 0
  9641.           THEN
  9642.            {error-handling}
  9643.           ELSE DrawPicture(PicHandle(pHndl))
  9644.  
  9645.  
  9646.     If your application wants data in the form of a  picture, and the
  9647. scrap contains only text, you can convert the text into a picture by
  9648. doing the following:
  9649.  
  9650.           tHndl := NewHandle(0);
  9651.           length := GetScrap(tHndl,'TEXT',offset);
  9652.           IF length < 0
  9653.             THEN
  9654.               {error-handling}
  9655.             ELSE
  9656.               BEGIN
  9657.               HLock(tHndl);
  9658.               pHndl := OpenPicture(thePort^.portRect);
  9659.               TextBox(tHndl^,length,thePort^.portRect,teJustLeft);
  9660.               ClosePicture;
  9661.               HUnlock(tHndl);
  9662.             END
  9663.  
  9664.  
  9665.     The Memory Manager procedures HLock and HUnlock are used to lock and
  9666. unlock blocks when handles are dereferenced (see the Memory Manager
  9667. Manual).
  9668.  
  9669. (note)
  9670.       To copy the desk scrap to the TextEdit scrap, use the
  9671.       TextEdit function TEFromScrap.
  9672.  
  9673.     Your application should pass its preferred data type to GetScrap. If
  9674. it doesn't prefer one data type over any other, it should try getting
  9675. each of the types it can read, and use the type that returns the lowest
  9676. offset. (A lower offset means that this data type was written before
  9677. the others, and therefore was preferred by the application that wrote
  9678. it.)
  9679.  
  9680. (note)
  9681.       If you're trying to read in a complicated picture, and
  9682.       there isn't enough room in memory for a copy of it, you
  9683.       can customize QuickDraw's picture retrieval so that
  9684.       DrawPicture will read the picture directly from the scrap
  9685.       file. (QuickDraw also lets you customize how pictures
  9686.       are saved so you can save them in a file; see the
  9687.       QuickDraw manual for details about customizing.)
  9688.  
  9689. (note)
  9690.       When reading in a picture from the scrap, allow a buffer
  9691.       of about 3.5K bytes.  (There's a convention that the
  9692.       application defining the picture won't call the QuickDraw
  9693.       procedure CopyBits for more than 3K, so a 3.5K buffer
  9694.       should be large enough for any picture.
  9695. \ ZeroScrap
  9696. 11
  9697. Function ZeroScrap : LONGINT;
  9698.  
  9699.     If the scrap already exists (in memory or on the disk), ZeroScrap
  9700. clears its contents; if not, the scrap is initialized in memory. You
  9701. must call ZeroScrap before the first time you call PutScrap. If no
  9702. error occurs, ZeroScrap returns the result code noErr; otherwise, it
  9703. returns an Operating System result code indicating an error.
  9704.  
  9705.     ZeroScrap also changes the scrapCount field of the record of
  9706. information provided by InfoScrap. This is useful for testing whether
  9707. the contents of the desk scrap have changed during the use of a desk
  9708. accessory. The application can save the value of the scrapCount field
  9709. when one of its windows is deactivated and a system window is
  9710. activated. Then, each time through its event loop, it can check to see
  9711. whether the value of the field has changed. If so, it means the desk
  9712. accessory called ZeroScrap (and, presumable, PutScrap) and thus changed
  9713. the contents of the desk scrap.
  9714.  
  9715. (warning)
  9716.          Just check to see whether the scrapCount field has
  9717.          changed; don't rely on exactly how it has changed.
  9718. \ PutScrap
  9719. 11
  9720. Function PutScrap (length: LONGINT; theType: ResType; source: Ptr) :
  9721.               LONGINT;
  9722.  
  9723.     PutScrap writes the data poointed to by the source parameter to the
  9724. desk scrap (in memory or on the disk). The length parameter indicates
  9725. the number of bytes to write, and theType is the data type.
  9726.  
  9727. (warning)
  9728.         The specified type must be different from the type of any
  9729.         data already in the desk scrap. If you write data of a
  9730.         type already in the scrap, the new data will be appended
  9731.         to the scrap, and subsequent GetScrap calls will still
  9732.         return the old data.
  9733.  
  9734.     If no error occurs, PutScrap returns the result code noErr;
  9735. otherwise, it returns an Operating System result code indicating an
  9736. error, or the following Scrap Manager result code:
  9737.  
  9738.        CONST noScrapErr = -100;  {desk scrap isn't initialized}
  9739.  
  9740. (note)
  9741.       To copy the TextEdit scrap to the desk scrap, use the
  9742.       TextEdit function TEToScrap.
  9743.  
  9744. (warning)
  9745.        Don't forget to call ZeroScrap to initialize the scrap or
  9746.        clear its previous contents.
  9747.  
  9748.  
  9749. \ FixRatio
  9750. 12
  9751. Function FixRatio (numer,demon: INTEGER) : Fixed;
  9752.  
  9753.     FixRatio returns the fixed-point quotient of numer and denom. Numer
  9754. or denom may be any signed integer. The result is truncated. If denom
  9755. is 0, FixRatio returns $7FFFFFFF with the sign of numer.
  9756. \ FixMul
  9757. 12
  9758. Function  FixMul (a,b: Fixed) : Fixed;
  9759.  
  9760.     FixMul returns the fixed-point product of a and b. The result is
  9761. computed MOD 65536, and truncated.
  9762. \ FixRound
  9763. 12
  9764. Function FixRound (x: Fixed) : INTEGER;
  9765.  
  9766.     Given a positive fixed-point number, FixRound rounds it to the
  9767. nearest integer and returns the result. If the value is halfway between
  9768. two integers (.5), it's rounded up. To round a negative fixed-point
  9769. number, multiply by -1, round, then multiply by -1 again.
  9770. \ NewString
  9771. 12
  9772. Function NewString (theString: Str255) : StringHandle;
  9773.  
  9774.     NewString allocates the specified string as a relocatable object on
  9775. the heap and returns a handle to it.
  9776. \ SetString
  9777. 12
  9778. Procedure SetString (h: StringHandle; theString: Str255);
  9779.  
  9780.     SetString sets the string whose handle is passed in h to the string
  9781. specified by theString.
  9782. \ GetString
  9783. 12
  9784. Function GetString (stringID: INTEGER) : StringHandle;
  9785.  
  9786.     GetString returns a handle to the string having the given resource
  9787. ID, reading it from the resource file if necessary. It calls the
  9788. Resource Manager function GetResource('STR ',stringID). If the resource
  9789. can't be read, GetString returns NIL.
  9790.  
  9791. (note)
  9792.       If your application uses a large number of strings,
  9793.       storing them in a string list in the resource file will
  9794.       be more efficient. You can access strings in a string
  9795.       list with GetIndString, as described below.
  9796. \ GetIndString
  9797. 12
  9798. Procedure GetIndString (VAR theString: Str255; strListID: INTEGER;
  9799.              Index: INTEGER);    [No trap macro]
  9800.  
  9801.     GetIndString returns in theString a string in the string list that
  9802. has the resource ID strListID. It reads the string list from the
  9803. resource file if necessary, by calling the Resource Manager function
  9804. GetResource('STR#',strListID). It returns the string specified by the
  9805. index parameter, which can range from 1 to the number of strings in the
  9806. list. If the resource can't be read or the index is out of range, the
  9807. empty string is returned.
  9808. \ Munger
  9809. 12
  9810. Function Munger (h: Handle; offset: LONGINT; ptrl: Ptr; lenl: LONGINT;
  9811.                     ptr2: Ptr; len2: LONGINT) : LONGINT;
  9812.  
  9813.     Munger (which rhymes with "plunger") lets you manipulate bytes in
  9814. the string of bytes (the "destination string") to which h is a handle.
  9815. The operation starts at the specified byte offset in the destination
  9816. string.
  9817.  
  9818. (note)
  9819.       Although the term "string" is used here, Munger does not
  9820.       assume it's manipulating a Pascal string; if you pass it
  9821.       a handle to a Pascal string, you must take into account
  9822.       the length byte.
  9823.  
  9824.     The exact nature of the operation done by Munger depends on the
  9825. values you pass it in two pointer/length parameter pairs. In general,
  9826. (ptr1,len1) defines a target string to be replaced by the second string
  9827. (ptr2,len2). If these four parameters are all positive and nonzero,
  9828. Munger looks for the target string in the destination string, starting
  9829. from the given offset and ending at the end of the string; it replaces
  9830. the first occurrence it finds with the replacement string and returns
  9831. the offset of the first byte past where the replacement occurred.
  9832. Figure 1 illustrates this; the bytes represent ASCII characters as
  9833. shown.
  9834.  
  9835.     Different operations occur if either pointer is NIL or either length
  9836. is 0:
  9837.  
  9838.     - If ptr1 is NIL, the substring of length len1 starting at the given
  9839.       offset is replaced by the replacement string. If len1 is
  9840.       negative, the substring from the given offset to the end of the
  9841.       destination string is replaced by the replacement string. In
  9842.       either case, Munger returns the offset of the first byte past
  9843.       where the replacement occurred.
  9844.  
  9845.  
  9846.     - If len1 is 0, (ptr2,len2) is simply inserted at the given offset;
  9847.       no text is replaced. Munger returns the offset of the first byte
  9848.       past where the insertion occurred.
  9849.  
  9850.     - If ptr2 is NIL, Munger returns the offset at which the targer
  9851.       string was found. The destination string isn't changed.
  9852.  
  9853.     - If ptr2 is NIL, Munger returns the offset at which the target
  9854.       string was found. The destination string isn't changed.
  9855.  
  9856.     - If len2 is 0 (and ptr2 is not NIL), the target string is deleted
  9857.       rather than replaced (since the replacement string is empty).
  9858.       Munger returns the offset at which the deletion occurred.
  9859.  
  9860.  
  9861.     If it can't find the target string in the destination string, Munger
  9862. returns a negative value.
  9863.  
  9864.     There's one case in which Munger performs a replacement even if it
  9865. doesn't find all of the target string. If the substring from the
  9866. offset to the end of the destination string matches the beginning of
  9867. the target string, the portion found is replaced with the replacement
  9868. string.
  9869.  
  9870. (warning)
  9871.         Be careful not to specify an offset that's greater than
  9872.         the length of the destination string, or unpredictable
  9873.         results may occur.
  9874.  
  9875. (note)
  9876.         The destination string must be in a relocatable block
  9877.         that was allocated by the Memory Manager. Munger
  9878.         accesses the string's length by calling the Memory
  9879.         Manager routines GetHandleSize and SetHandleSize.
  9880. \ PackBits
  9881. 12
  9882. Procedure PackBits (VAR srcPtr,DstPtr: Ptr; srcBytes: INTEGER);
  9883.  
  9884.     PackBits compresses srcBytes bytes of data starting at srcPtr and
  9885. stores the compressed data at dstPtr. The value of srcBytes should not
  9886. be greater than 127. Bytes are compressed when there are three or more
  9887. consecutive equal bytes. After the data is compressed, srcPtr is
  9888. incremented by srcBytes and dstPtr is incremented by the number of
  9889. bytes that the data was compressed to. In the worst case, the
  9890. compressed data can be one byte longer than the original data.
  9891.  
  9892.     PackBits is usually used to compress QuickDraw bit images; in this
  9893. case, you should call it for one row at a time. (Because of the
  9894. repeating patterns in QuickDraw images, there are more likely to be
  9895. consecutive equal bytes there than in other data.)  Use UnpackBits
  9896. (below) to expand data compressed by PackBits.
  9897. \ UnpackBits
  9898. 12
  9899. Procedure UnpackBits (VAR SrcPtr, DstPtr: Ptr; dstBytes: Integer);
  9900.  
  9901.     Given in SrcPtr a pointer to the data that was compressed by PackBits,
  9902. UnpackBits expands the data and stores the result as DstPtr. DstBytes is
  9903. the length that the expanded data will be; it should be the value that was
  9904. passed to PackBits in the SrcBytes parameter. After the data is expanded,
  9905. srcPtr is incremented by the number of bytes that were expanded and dstPtr
  9906. is incremented by dstBytes.
  9907. \ BitTst
  9908. 12
  9909. Function BitTst (BytePtr: Ptr; bitNum: Longint): Boolean;
  9910.  
  9911.     BitTst tests wether a given bit is set and returns TRUE if so or FALSE
  9912. if not. The bit is specified by bitNum, an offset from the high-order bit
  9913. of the byte pointed to by BytePtr.
  9914. \ BitSet
  9915. 12
  9916. Procedure BitSet (BytePtr: Ptr; bitNum: Longint);
  9917.  
  9918.     BitSet sets the bit specified by bitNum, an offset from the high-order
  9919. bit of the byte pointed to by BytePtr.
  9920. \ BitClr
  9921. 12
  9922. Procedure BitClr (BytePtr: Ptr; bitNum: Longint);
  9923.  
  9924.     BitClr clears the bit specified by bitNum, an offset from the
  9925. high-order bit of the byte pointed to by BytePtr.
  9926. \ BitAnd
  9927. 12
  9928. Function BitAnd (Value1, Value2: Longint): Longint;
  9929.  
  9930.     BitAnd returns the value of the AND logical operation on the bits
  9931. comprising the given long integers ( value1 AND value2).
  9932.  
  9933.     If you use the MPW Pascal Compiler, DON'T USE THIS FUNCTION… Instead, use the BAnd Function.
  9934. \ BitOr
  9935. 12
  9936. Function BitOr (Value1, Value2: Longint): Longint;
  9937.  
  9938.     BitOr returns the value of the OR logical operation on the bits
  9939. comprising the given long integers ( vallue1 OR value2).
  9940.  
  9941.     If you use the MPW Pascal Compiler, DON'T USE THIS FUNCTION… Instead, use the BOr Function.
  9942. \ BitXor
  9943. 12
  9944. Function BitXor (Value1, Value2: Longint): Longint;
  9945.  
  9946.     BitXor returns the value of the XOR logical operation on the bits
  9947. comprising the given long integers ( vallue1 XOR value2).
  9948. \ BitNot
  9949. 12
  9950. Function BitNot (Value: Longint): Longint;
  9951.  
  9952.     BitNot returns the result of the NOT logical opeation on the bits
  9953. comprisisng the given long integer (NOT value).
  9954. \ BitShift
  9955. 12
  9956. Function BitShift (Value: Longint; count: Integers): Longint;
  9957.  
  9958.     BitShift logically shifts the bits of the giveb long integer. The count
  9959. parameter specifies the direction and the extent of the shift, and is token
  9960. MOD 32. If count is positive, BitShift shifts that many positions to the
  9961. left; if count is negative, it shifts to the right. Zeroes are shifted into
  9962. empty positions at their end.
  9963. \ HiWord
  9964. 12
  9965. Function HiWord (x: Longint): Integer;
  9966.  
  9967.     HiWord returns the high-order word of the given long integer. One use
  9968. of this function is to extract the integer part of a fixed-point number.
  9969. \ LoWord
  9970. 12
  9971. Function LoWord (x: Longint): Integer;
  9972.  
  9973.     LoWord returns the low-order word of the given long integer. One use
  9974. of this function is to extract the fractional part of a fixed-point
  9975. number.
  9976.  
  9977.     Note: If you're dealing with a long intger that contains two separate
  9978.     integer values, you can define a variant record instead of using
  9979.     HiWord and LoWord. For example, for fixed-point numbers, you can
  9980.     define the following type:
  9981.  
  9982.       TYPE FixedAndInt = RECORD CASE Integer OF
  9983.                             1: (FixedView: Fixed);
  9984.                             2: (intView:   RECORD
  9985.                                             Whole: Integer;
  9986.                                             Part : Integer;
  9987.                                            END;)
  9988.                           END;
  9989.  
  9990.     If you declare x to be of type FixedAndInt, you can access it as a
  9991.     fixed-point value with x.FixedView, or access the integer part with
  9992.     x.intView.Whole aand the fractional part with x.intView.part.
  9993. \ LongMul
  9994. 12
  9995. Procedure LongMul (a,b: Longint; VAR dest: Int64bit);
  9996.  
  9997.     LongMul multiplies the given long integers and returns the signed
  9998. result in dest which has the following data type:
  9999.  
  10000.     TYPE Int64Bit = RECORD
  10001.                       HiLong: Longint;
  10002.                       LoLong: Longint;
  10003.                     END;
  10004. \ ScreenRes
  10005. 12
  10006. Procedure ScreenRes (VAR scrnHRes, scrnVRes: Integer);
  10007.  
  10008.     ScreenRes returns the resolution of the screen of the macintosh being
  10009. used. ScrnHRes and scrnVRes are the number of pixels per inch horizontally
  10010. and verticaly, respectively.
  10011.  
  10012.         ____________________________________________________________
  10013.          Assembly-language note: The number of pixels per  inch
  10014.          horizontally is stored in the global variable ScrHRes, and
  10015.          the number of pixels per inch vertically is stored in
  10016.          ScrVRes.
  10017.         ____________________________________________________________
  10018. \ GetIcon
  10019. 12
  10020. Function GetIcon (IconId: Integer): Handle;
  10021.  
  10022.     GetIcon returns a handle to the icon having the given resource ID,
  10023. reading it from the resource file if necessary. It calls the resource
  10024. manager function GetResource ('ICON', IconId). If the resource can't be
  10025. read, GetIcon returns NIL.
  10026. \ PlotIcon
  10027. 12
  10028. Procedure PlotIcon (TheRect: Rect; TheIcon: Handle);
  10029.     PlotIcon draws the icon whose handle is theIcon in the rectangle
  10030. TheRect, which is in the local coordinate of the current grafport. It
  10031. calls the QuickDraw procedure CopyBits and uses the srcCopy transfer mode.
  10032. \ GetPattern
  10033. 12
  10034. Function GetPattern (PatID: Integer): PatHandle;
  10035.  
  10036.     GetPattern returns a handle to the pattern  having the given resource
  10037. ID, reading it from the resource file if necessary. It calls the resource
  10038. manager function  GetResource ('PAT ', PatId). If the resource can't be
  10039. read, GetPattern returns NIL. The PatHandle data type is defined in the
  10040. toolbox utilities as follows:
  10041.  
  10042.     TYPE  PatPtr    = ^Pattern;
  10043.           PatHandle = ^PatPtr;
  10044. \ GetIndPattern
  10045. 12
  10046. Function GetIndPattern (VAR ThePattern: Patter; PatLisId: Integer; Index:
  10047.                         Integer);
  10048.  
  10049.     GetIndPattern returns in the pattern a pattern in the pattern list
  10050. that has the resource ID PatListID. It reads the pattern list from the
  10051. resource file if necessary, by calling the Resource Manager function
  10052. GetResource ('PAT#', PatListID). It returns the pattern specified by the
  10053. index parameter, which can range from 1 to the number of patterns in the
  10054. pattern list.
  10055.  
  10056.     There's a pattern list in the system resource file that contains the
  10057. standard Macintosh patterns used by MacPaint. Its resource ID is :
  10058.  
  10059.     CONST   SysPatListID = 0;
  10060. \ GetCursor
  10061. 12
  10062. Function GetCursor (CursorID: Integer): CursHandle;
  10063.  
  10064.     GetCursor returns a handle to the cursor having the given resource ID,
  10065. reading it forme the resource file if necessary. It calls the resource
  10066. manager function GetResource ('CURS', CursorIdD). If the resource can't be
  10067. read, GetCursor returns NIL. The CursHandle data type is defined in the
  10068. toolbox utilities as follows:
  10069.  
  10070.     TYPE    CursPtr    = ^Cursor;
  10071.             CursHandle = ^CursPtr;
  10072.  
  10073.     The standard cursors are defined in the system resource file. Their
  10074. resources ID are:
  10075.  
  10076.     CONST   iBeamCursor = 1; {to select text}
  10077.             crossCursor = 2; {to draw graphics}
  10078.             plusCursor  = 3; {to select cells in structured documents}
  10079.             watchCursor = 4; {to indicate a too long wait}
  10080.  
  10081.  
  10082.     Note: You can set the cursor with the quickdraw procedure SetCursor.
  10083.     The arrow cursor is defined in QuickDraw as a global variable named
  10084.     Arrow.
  10085. \ ShieldCursor
  10086. 12
  10087. Procedure ShieldCursor (shieldRect: Rect; OffsetPt: Point);
  10088.  
  10089.     If the cursor and the given rectangle intersect, ShieldCursor hides
  10090. the cursor. If they don't intersect, the cursor remains visible while the
  10091. mouse isn't moving, but is hidden when the mouse moves.
  10092.  
  10093.     Like the QuickDraw procedure HideCursor, ShieldCursor decrements the
  10094. cursor level,  and should be balanced by a call to ShowCursor.
  10095.  
  10096.     The rectangle may be given in local or global coordinates:
  10097.  
  10098. •  If they're global coordinates, pass (0, 0) in OffsePt.
  10099. •  If they're a grafport's local coordinates, pass the top left corner of
  10100.    the grafport's boundary rectangle in OffsetPt. (Like the QuickDraw
  10101.    procedure LocalToGlobal, ShieldCursor will offset the coordinates of
  10102.    the rectangle by the coordinate of this point.)
  10103. \ GetPicture
  10104. 12
  10105. Function GetPicture (PicID: Integer): PicHandle;
  10106.  
  10107.     GetPicture returns a handle to the picture having the given resource
  10108. ID, reading it from the resource file if necessary. It calls the resource
  10109. Manager function GetResource ('PICT', PicID). If the resource can't be
  10110. read GetPicture returns NIL. The PicHandle data type is defined in
  10111. QuickDraw.
  10112. \ DeltaPoint
  10113. 12
  10114. Function DeltaPoint (ptA, ptB: Point): Longint;
  10115.  
  10116.     DeltaPoint substracts the coordinates of ptB from the coordinates of
  10117. ptA. The high-order word of the result is the difference of the vertical
  10118. coordinates, and the low-order word is the difference of the horizontal
  10119. coordinates.
  10120.  
  10121.     NOTE : The QuickDraw procedure SubPt also substracts the coordinates
  10122.     of one point, but returns the result in a VAR parameter of type Point.
  10123. \ SlopeFromAngle
  10124. 12
  10125. Function SlopeFromAngle (Angle: Integer): Fixed;
  10126.  
  10127.     Given an angle, SlopeFromAngle returns the slope dh/dv of the line
  10128. forming that angle with the Y-axis (dh/dv is the horizontal change divided
  10129. by the vertical  change between any two points on the line). The angle is
  10130. treated MOD 180, and its degrees measured from 12 o'clock; positive
  10131. degrees are measured clockwise, negative degrees are measured
  10132. counterclockwise (for example, 90 degrees is at 3 o'clock, and -90 degrees
  10133. is at 9 o'clock). Positive y is down; positive x is to the right.
  10134. \ AngleFromSlope
  10135. 12
  10136. Function AngleFromSlope (Slope: Fixed): Integer;
  10137.  
  10138.     Given the slope dh/dv of a line (see SlopeFromAngle), AngleFromSlope
  10139. returns the angle formed by that line and the y-axis. The angle returned
  10140. is between 1 and 180 (inclusive), in degrees measured clockwise from 12
  10141. o'clock.
  10142.  
  10143.     AngleFromSlope is meant for use when speed is much more important than
  10144. accuracy - its integer result is guaranted to be one degree of the correct
  10145. answer,  but not necessarily within half a degree. However the equation
  10146.  
  10147.     AngleFromSlope(SlopeFromAngle(x))= x
  10148.  
  10149. is true for all x except 0 (although reverse is not).
  10150.  
  10151.     NOTE : SlopeFromAngle(0) is 0, and AngleFromSlope(0) is 180.
  10152. \ FracMul
  10153. 12
  10154. Function FracMul (x,y: Fract) : Fract;
  10155.  
  10156. FracMul returns x * y. Note that FracMul effects
  10157.  
  10158. “type   *   Fract   —>  type”:
  10159. Fract   *   Fract   —>  Fract
  10160. LONGINT *   Fract   —>  LONGINT
  10161. Fract   *   LONGINT —>  LONGINT
  10162. Fixed   *   Fract   —>  Fixed
  10163. Fract   *   Fixed   —>  Fixed
  10164. \FixDiv
  10165. 12
  10166. Function FixDiv (x,y: Fixed) : Fixed;
  10167.  
  10168. FixDiv returns x / y.
  10169. \FracDiv
  10170. 12
  10171. Function FracDiv (x,y: Fract) : Fract;
  10172.  
  10173. FracDiv returns x / y.
  10174. \FracSqrt
  10175. 12
  10176. Function FracSqrt (x: Fract) : Fract;
  10177.     FracSqrt returns the square root of x, with x interpreted as
  10178. unsigned in the range 0 through 4–(2–30), inclusive:  That is, bit 15 in
  10179. Figure 1 has weight 2 rather than –2. The result, too, is unsigned
  10180. in the range 0 through 2, inclusive.
  10181. \FracCos
  10182. 12
  10183. Function FracCos (x: Fixed) : Fract;
  10184.     FracCos and FracSin return the cosine and sine of their radian
  10185. arguments, respectively. The hexadecimal value 0.C910 (which is
  10186. FixATan2(1,1)) is the approximation to π/4 used for argument reduction.
  10187. Thus, FracCos and FracSin are nearly periodic, but with period 2*P
  10188. instead of 2*π, where P=3.1416015625 and π, of course, is 3.14159265....
  10189. \FracSin
  10190. 12
  10191. Function FracSin (x: Fixed) : Fract;
  10192.  
  10193.     FracCos and FracSin return the cosine and sine of their radian
  10194. arguments, respectively. The hexadecimal value 0.C910 (which is
  10195. FixATan2(1,1)) is the approximation to π/4 used for argument reduction.
  10196. Thus, FracCos and FracSin are nearly periodic, but with period 2*P
  10197. instead of 2*π, where P=3.1416015625 and π, of course, is 3.14159265....
  10198. \FixATan2
  10199. 12
  10200. Function FixATan2 (x,y: LONGINT) : Fixed;
  10201.  
  10202.     FixATan2 returns the arctangent of y / x in radians.
  10203. \Long2Fix
  10204. 12
  10205. Function Long2Fix (x: LONGINT) : Fixed;
  10206.  
  10207.     Long2Fix, Fix2Long, Fix2Frac, and Frac2Fix convert between
  10208. fixed-point types.
  10209. \Fix2Long
  10210. 12
  10211. Function Fix2Long (x: Fixed) : LONGINT;
  10212.  
  10213. Long2Fix, Fix2Long, Fix2Frac, and Frac2Fix convert between fixed-point
  10214. types.
  10215. \Fix2Frac
  10216. 12
  10217. Function Fix2Frac (x: Fixed) : Fract;
  10218.  
  10219. Long2Fix, Fix2Long, Fix2Frac, and Frac2Fix convert between fixed-point
  10220. types.
  10221. \Frac2Fix
  10222. 12
  10223. Function Frac2Fix (x: Fract) : Fixed;
  10224.  
  10225. Long2Fix, Fix2Long, Fix2Frac, and Frac2Fix convert between fixed-point
  10226. types.
  10227.  
  10228. \Fix2X
  10229. 12
  10230. Function Fix2X  (x: Fixed) : Extended;
  10231.  
  10232. Fix2X, X2Fix, Frac2X, and X2Frac convert between Fixed and Fract
  10233. and the Extended floating-point type. These functions do not set
  10234. floating-point exception flags.
  10235. \X2Fix
  10236. 12
  10237.  
  10238. Fix2X, X2Fix, Frac2X, and X2Frac convert between Fixed and Fract
  10239. and the Extended floating-point type. These functions do not set
  10240. floating-point exception flags.
  10241. Function X2Fix  (x: Extended) : Fixed;
  10242. \Frac2X
  10243. 12
  10244. Function Frac2X (x: Fract) : Extended;
  10245.  
  10246. Fix2X, X2Fix, Frac2X, and X2Frac convert between Fixed and Fract
  10247. and the Extended floating-point type. These functions do not set
  10248. floating-point exception flags.
  10249. \X2Frac
  10250. 12
  10251. Function X2Frac (x: Extended) : Fract;
  10252.  
  10253. Fix2X, X2Fix, Frac2X, and X2Frac convert between Fixed and Fract
  10254. and the Extended floating-point type. These functions do not set
  10255. floating-point exception flags.
  10256.  
  10257. \ InitPack
  10258. 13
  10259. Procedure InitPack (packID: INTEGER);
  10260.  
  10261.     InitPack enables you to use the package specified by packID, which
  10262. is the package's resourceID. (It gets a handle that will be used later
  10263. to read the package into memory.)
  10264. \ InitAllPacks
  10265. 13
  10266. Procedure InitAllPacks;
  10267.  
  10268.     InitAllPacks enables you to use all Macintosh packages (as though
  10269. InitPack were called for each one). It wil already have been called
  10270. when your application starts up.
  10271. \ IUDateString
  10272. 13
  10273. Procedure IUDateString (dateTime: LongInt; form: DateForm; VAR result:
  10274.                         Str255);
  10275.  
  10276.     Given a date and time as returned by the Operating System Utility
  10277. routine ReadDateTime, IUDateString returns in the result parameter a
  10278. string that represents the corresponding date. The form parameter has
  10279. the following data type:
  10280.  
  10281.        TYPE DateForm = (shortDate,longDate,abbrevDate);
  10282.  
  10283.     ShortDate requests the short date format, longDate the long date,
  10284. and abbrevDate the abbreviated long date. IUDateString determines the
  10285. exact format from international resource 0 for the short date of 1 for
  10286. the long date. See Figure I-1 above for examples of the standard
  10287. formats. Notice that the short date contains a space in place of  a
  10288. leading zero when the format specifies "no leading zero", so the length
  10289. of the result is always the same for short dates.
  10290.  
  10291.     If the abbreviated long date is requested and the abbreviation
  10292. length in international resource 1 is greater than the actual length of
  10293. the name being abbreviated, IUDateString fills the abbreviation with NUL
  10294. characters; the abbreviation length should not be greater than 15, the
  10295. maximum name length.
  10296. \ IUDatePString
  10297. 13
  10298. Procedure IUDatePString (dateTime: LongInt; form: DateForm; VAR result:
  10299.             Str255; intlParam: Handle);
  10300.  
  10301.  
  10302.     IUDatePString is the same as IUDateString except that it determines
  10303. the exact format of the date from the resource whose handle is passed in
  10304. intlParam, overriding the resource that would otherwise be used.
  10305. \ IUTimeString
  10306. 13
  10307. Procedure IUTimeSTring (dateTime: LongInt; wantSeconds: BOOLEAN; VAR
  10308.             result: Str255);
  10309.  
  10310.     Given a date and time as returned by the Operating System Utility
  10311. routein ReadDateTime, IUTimeString returns in the result parameter a
  10312. string that represents the corresponding time of day. If wantSeconds
  10313. is TRUE, seconds are included in the time; otherwise, only the hour and
  10314. minute are included. IUTimeSting determines the time format from
  10315. internation resource 0. See Figure I-1 above for examples of the
  10316. standard formats. Notice that the time contains a space in place of a
  10317. leading zero when the format specifies "no leading zero", so the length
  10318. of the result is always the same.
  10319. \ IUTimePString
  10320. 13
  10321. Procedure IUTimePString (dateTime: LongInt; wantSeconds: BOOLEAN; VAR
  10322.             result: str255; intlParam: Handle);
  10323.  
  10324.     IUTimePString is the same as IUTimeString except that it determines
  10325. the time format from the resource whose handle is passed in intlParam,
  10326. overriding the resource that would otherwise be used.
  10327. \ IUMetric
  10328. 13
  10329. Function IUMetric : BOOLEAN;
  10330.  
  10331.     If international resource 0 specifies that the metric system is to
  10332. be used, IUMetric retruns TRUE; otherwise, it returns FALSE.
  10333. \ IUGetIntl
  10334. 13
  10335. Function IUGetIntl (theID: INTEGER) : Handle;
  10336.  
  10337.     IUGetIntl returns a handle to the international resource numbered
  10338. theID (0 or 1). It calls the Resource Manager function
  10339. GetResource('INTL',theID). For example, if you want to access
  10340. individual fields of international resource 0, you can do the
  10341. following:
  10342.  
  10343.      VAR myHndl: Handle;
  10344.          int0: Intl0Hndl;
  10345.      ...
  10346.      myHndl := IUGetIntl(0);
  10347.      int0 := POINTER(ORD(myHndl));
  10348. \ IUSetIntl
  10349. 13
  10350. Procedure IUSetIntl (refNum: INTEGER; thefID; INTEGER; intlParam:
  10351.             Handle);
  10352.  
  10353.     In the resource file having the reference number refNum, IUSetIntl
  10354. sets the international resource numbered theID (0 or 1) to the data
  10355. pointed to by tintlParam. The data may be either an existing resource
  10356. okr data that hasn't yet been written to a resource file. IUSetIntl
  10357. adds the resource to the specified file or replaces the resource if it's
  10358. already there.
  10359. \ IUCompString
  10360. 13
  10361. Function IUCompString (aStr,bStr: Str255) : INTEGER;  [Pascal only]
  10362.  
  10363.     IUCompString compares aStr and bStr as described above under
  10364. "International String Comparison", taking both primary and secondary
  10365. ordering into consideration. It returns one of the values listed
  10366. below.
  10367.  
  10368.       Result   Meaning                           Example
  10369.                                               aStr     bStr
  10370.        -1       aStr is less than bStr       'Ab'     'ab'
  10371.         0       aStr  equals bStr            'Ab'     'Ab'
  10372.         1       aStr is greater than bStr    'Ac'     'ab'
  10373. \ IUMagString
  10374. 13
  10375. Function IUMagString (aPtr,bPtr: Ptr; aLen,bLen: INTEGER) : INTEGER;
  10376.  
  10377.     IUMagString is the same as IUCompString (above) except that instead
  10378. of comparing two Pascal strings, it compares the string defined by aPtr
  10379. and aLen to the string defined by bPtr and bLen. The pointer points to
  10380. the first character of the string (any byte in memory, not necesarily
  10381. word-aligned), and the length specifies the number of characters in the
  10382. string.
  10383. \ IUEqualString
  10384. 13
  10385. Function IUEqualString (aStr,bStr: Str255) : INTEGER;   [Pascal only]
  10386.  
  10387.     IUEqualString comapares aStr and bStr for equality without regard
  10388. for secondary ordering, as described above under "international String
  10389. Comparison". If the strings are equal, it returns 0; otherwise, it
  10390. returns 1. For example, if the strings are 'Rose' and 'rose',
  10391. IUEqualString considers them equal and returns 0.
  10392.  
  10393. (note)
  10394.       See also EqualString in the Operating System Utilities
  10395.       manual *** doesn't yet exist***.
  10396. \ IUMagIDString
  10397. 13
  10398. Function IUMagString (aPtr,bPtr: Ptr; aLen,bLen: INTEGER) : INTEGER;
  10399.  
  10400.     IUMagIDString is the same as IUEqualString except that instead of comparing two Pascal strings, it compares the string defined by aPtr and aLen to the string defined by bPtr and bLen. The pointer points to the first character of the string (any byte in memory, not necessarily word-aligned), and the length specifies the number of4 characters in the string.
  10401. \ NumToString
  10402. 13
  10403. Procedure NumToString (theNum: LongInt; VAR theStringd: Str255);
  10404.  
  10405. ____________________________________________________________________
  10406.  
  10407. Trap macro     _NumToString
  10408.  
  10409. On entry       A0:  pointer to theString (length byte followed
  10410.                   by characters)
  10411.  
  10412.              D0:  theNum (long integer)
  10413.  
  10414. On exit         A0:  pointer to theString
  10415.  
  10416. _____________________________________________________________________
  10417.  
  10418.     NumToString converts theNum to a string that represents its decimal
  10419. value, and returns the result in theString. If the value is negative,
  10420. the string begins with a minus sign; otherwise, the sign is omitted.
  10421. Leading zeroes are suppressed, except that the value 0 produces '0'.
  10422. For example:
  10423.  
  10424.      theNum          theString
  10425.       12              '12'
  10426.      -23             '-23'
  10427.        0              '0'
  10428. \ StringToNum
  10429. 13
  10430. Procedure StringToNum (theString: Str255; VAR theNum: LongInt);
  10431.  
  10432. ___________________________________________________________________
  10433.  
  10434. Trap macro     _StringToNum
  10435.  
  10436. On entry       A0:  pointer to theString (length byte followed
  10437.                   by characters)
  10438.  
  10439. On exit        DO:  theNum (long integer)
  10440.  
  10441. ___________________________________________________________________
  10442.  
  10443.  
  10444.     Given a string representing a decimal integer, StringToNum converts
  10445. it to the corresponding integer and returns the result in theNum. The
  10446. string may begin with a plus or minus sign. For example:
  10447.  
  10448.       theString          theNum
  10449.         '12'               12
  10450.        '-23'              -23
  10451.         '-0'                0
  10452.        '055'               55
  10453.  
  10454.     The magnitude of the integer is converted modulo 2^32, and the
  10455. 32-bit result is negated if the string begins with a minus sign; integer
  10456. overflow occurs if the magnitude is greater than 2^31-1. (Negation is
  10457. done by taking the two's complement--reversing the state of each bit
  10458. adn then ading 1.)  For example:
  10459.  
  10460.         theString                                   theNum
  10461.        '2147483648'  (magnitude is 2^31)          -2147483648
  10462.       '-2147483648'                               -2147483648
  10463.        '4294967295'  (magnitude is 2^31)              -1
  10464.       '-4294967295'                                    1
  10465.  
  10466.     StringToNum doesn't actually check whether the characters in the
  10467. string are between '0' and '9'; instead, since the ASCII codes for '0'
  10468. through '9' are $30 through $39, it just masks off the last four bits
  10469. and uses them as a digit. For example, '2:' is converted to the number
  10470. 30 because the ASCI code for ':' is $3A. Leading spaces before the
  10471. first digit are treated as zeroes, since the ASCII code for a space is
  10472. $20. Given that the ASCII codes for 'C', 'A', and 'T' are $43, $41, and
  10473. $54, respectively, consider the following examples:
  10474.  
  10475.  
  10476.       theString              theNum
  10477.         'CAT'                  314
  10478.        '+CAT'                  314
  10479.        '-CAT'                 -314
  10480. \ SFPutFile
  10481. 13
  10482. Procedure SFPutFile (where: Point; prompt: Str255; origName: Str255;
  10483.                     dlgHook: ProPtr; VAR reply: SFReply);
  10484.  
  10485.     SFPutFile displays a dialog box allowing the user to specify a file
  10486. to which data will be written (as during a Save or Save As command). It
  10487. then repeatedly gets and handles events until the user either confirms
  10488. the command after entering an appropriate file name or aborts the
  10489. command by clicking Cancel in the dialog. It reports the user's reply
  10490. by filling the fields of the reply record specified by the reply
  10491. parameter, as described above; the fType field of this record isn't
  10492. used.
  10493.  
  10494.     The general appearance of the standard SFPutFile dialog box is shown
  10495. in Figure S-2. The where parameter specifies the location of the top
  10496. left corner of the dialog box in global coordinates. The prompt
  10497. parameter is a line of text to be displayed as a statText item in the
  10498. dialog box, where shown in Figure S-2. The origName parameter contains
  10499. text that appears as an enabled, selected editText item; for the
  10500. standard document-saving commands, it should be the current name of the
  10501. document, or the empty string (to display an insertion point) if the
  10502. document hasn't been named yet.
  10503.  
  10504.     If you want to use the standard SFPutFile dialog box, pass NIL for
  10505. dlgHook; otherwise, see the information for advanced programmers below.
  10506.  
  10507.     SFPutFile  repeatedly calls the Dialog Manager procedure
  10508. ModalDialog. When an event involving an enabled dialog item occurs,
  10509. ModalDialog handles the event andf returns the item number, and
  10510. SFPutFile responds as follows:
  10511.  
  10512.    - If the Eject or Drive button is clicked, or a disk is inserted,
  10513.      SFPutFile responds as described above under "About the Standard
  10514.      File Package".
  10515.  
  10516.    - Text entered into the editText item is stored in the fName field
  10517.      of the reply record. (SFPutFile keeps track of whetehr there's
  10518.      currently any text in the item, and makes the Save button inactive
  10519.      if not.)
  10520.  
  10521.    - If the Save button is clicked, SFPutFile determines whether the
  10522.      file name in the fName field of the reply record is appropriate.
  10523.      If so, it returns control to the application with the first field
  10524.      of the reply record set to TRUE; otherwise, it responds
  10525.      accordingly, as described below.
  10526.  
  10527.   - If the Cancel button in the dialog is clicked, SFPutFile returns
  10528.     control to the application with the first field of the reply
  10529.     record set to FALSE.
  10530.  
  10531. (note)
  10532.        Notice that disk insertion is one of the user actions
  10533.        listed above, even though ModalDialog normally ignores
  10534.        disk-inserted events. The reason this works is that
  10535.        SFPutFile calls ModalDialog with a filterProc function
  10536.        that checks for a disk-inserted event and returns a
  10537.        "fake", very large item number if one occurs; SFPutFile
  10538.        recognizes this item number as an indication that a disk
  10539.        was inserted.
  10540.  
  10541.     The situations that may cause an entered name to be inappropriate,
  10542. and SFPutFile's response to each, are as follows:
  10543.  
  10544.      - If a file with the specified name already exists on the disk and
  10545.        is different from what was passed in the origName parameter, the
  10546.        alert in Figure S-3 is displayed. If the user clicks Yes, the
  10547.        file name is appropriate.
  10548.  
  10549.      - If the disk to which the file shoud be written is locked, the
  10550.        alert in Figure S-4 is displayed. If a system error occurs, a
  10551.        similar alert is displayed, with a corresponding message
  10552.        explaining the problem.
  10553.  
  10554. (note)
  10555.        The user may specify a disk name (preceding the file name
  10556.        and separated from it by a colon). If the disk isn't
  10557.        currently in a drive, an alert similar to the one in
  10558.        Figure S-4 is displayed. The ability to specify a disk
  10559.        name is supported for historical reasons only; users
  10560.        should not be encouraged to do it.
  10561.  
  10562.     After the user clicks No or Cancel in response to one of these
  10563. alerts, SFPutFile dismisses the alert box and continues handling events
  10564. (so a different name may be entered).
  10565.  
  10566. Advanced programmers:  You can create your own dialog box rather than
  10567. use the standard SFPutFile dailog. To do this, you must provide your
  10568. own dialog template and store it in your application's resource file
  10569. with the same resource ID that the standard template has in the system
  10570. resource file:
  10571.  
  10572.         CONST putDlgID = -3999;   {SFPutFile dialog template ID}
  10573.  
  10574. (note)
  10575.        The SFPPutFile procedure, described below lets you use
  10576.        any resource ID for your nonstandard dialog box.
  10577.  
  10578.     Your dialog template must specify that the dialog window be
  10579. invisible, and your dialog must contain all the standard items, as
  10580. listed below. The appearance and location of these items in your dialog
  10581. may be different. You can make an item "invisible" by giving it a
  10582. display rectangle that's off the screen. The display rectangle for each
  10583. item in the standard dialog box is given below. The rectangle for the
  10584. standard dialog box itself is (0,0,304,104).
  10585.  
  10586.  
  10587.    Item Number  Item                     Standard display rectangle
  10588.     1       Save button                  (12,74,82,92)
  10589.     2       Cancel button                (114,74,184,92)
  10590.     3       Prompt string (statText)     (12,12,184,28)
  10591.     4       UserItem for disk name       (209,16,295,34)
  10592.     5       Eject button                 (217,43,287,61)
  10593.     6       Drive button                 (217,74,287,92)
  10594.     7       EditText item for file name  (14,34,182,50)
  10595.     8       UserItem for gray line       (200,16,201,88)
  10596.  
  10597.  
  10598. (note)
  10599.        Remember that the display rectangle for any "invisible"
  10600.        item must be at least about 20 pixels wide. *** This
  10601.        will be discussed in a future draft of the Dialog Manager
  10602.        manual. ***
  10603.  
  10604.  
  10605.     If your dialog has addition items beyond the standard ones, or if
  10606. you want to handle any of the standard items in a nonstandard manner,
  10607. you must write your own dlgHook funciton and point to it with dlgHook.
  10608. Your dlgHook function should have two parameters and return an integer
  10609. value. For example, this is how it wokuld be declared if it were named
  10610. MyDlg:
  10611.  
  10612.        FUNCTION MyDlg (item: INTEGER; theDialog: DialogPtr) : INTEGER;
  10613.  
  10614.     Immediately after calling ModalDialog, SFPutFile calls your dlgHook
  10615. Function, passing it the item number returned by ModalDialog and a
  10616. pointer to the dialog record describing your dialog box. Using these
  10617. two parameters, your dlgHook function should determine how to handle
  10618. the event. There are predefined constants for the item numbers of
  10619. standard enabled items, as follows:
  10620.  
  10621.       CONST putSave   = 1;   {Saver button}
  10622.             putCancel = 2;   {Cancel button}
  10623.         putEject  = 5;   {Eject button}
  10624.         putDrive  = 6;   {Drive button}
  10625.         putName   = 7;   {editText item for file name}
  10626.  
  10627.     ModalDialog also returns the "fake" item number 100 when a disk-
  10628. inserted event occurs, as detected by its filterProc function.
  10629.  
  10630.     After handling the event (or, perhaps, after ignoring it) the
  10631. dlgHook function must return an item number to SFPutFile. If the item
  10632. number is one of those listed above, SFPutFile responds in the standard
  10633. way; otherwise, it does nothing.
  10634.  
  10635. (note)
  10636.        For advanced programmers who want to change the
  10637.        appearance of the alerts displayed when an inappropriate
  10638.        file name is entered, the resource IDs of those alerts in
  10639.        the system resource file are listed below.
  10640.  
  10641.  
  10642.        Alert                   Resource ID
  10643.        Existing file             -3996
  10644.        Locked disk               -3997
  10645.        System error              -3995
  10646.        Disk not found            -3994
  10647. \ SFPPutFile
  10648. 13
  10649. Procedure SFPPutFile (where: Point; prompt: SStr255; origNmae: Str255;
  10650.              dlgHook: ProcPtr; VAR reply: SFReply; dlgID: INTEGER;
  10651.          filterProc: ProcPtr);
  10652.  
  10653.     SFPPutFile is an alternative to SFPutFile for advanced programmers
  10654. who want to use a nonstandard dialog box. It's the same as SFPutFile
  10655. except for the two additional parameters dlgID and filterProc.
  10656.  
  10657.     DlgID is the resource ID of the dialog template to be used instead
  10658. of the standard one (so you can use whatever ID you wish rather than the
  10659. same one as the standard).
  10660.  
  10661.     The filterProc parameter determines how ModalDialog will filter
  10662. events when called by SFPPutFile. If filterProc is NIL, ModalDialog
  10663. does the standard filtering that it does when called by SFPutFile;
  10664. otherwise, filterProoc should point to a function for ModalDialog to
  10665. execute afterdoing the standard filterilng. THe function must be the
  10666. same as one you'd pass directly to ModalDialog in its filterProc
  10667. parameter. (See the Dialog Manager manual for more information.)
  10668. \ SFGetFile
  10669. 13
  10670. Procedure SFGetFile (where: Point; prompt: Str255; fileFilter: ProcPtr;
  10671.                     numTypes: INTEGER; typeList: SFTypeList;
  10672.                     dlgHook: ProcPtr; VAR reply: SFReply);
  10673.  
  10674.     SFGetFIle displays a dialog box listing the names of a specific
  10675. group of files from which the user can select one to be opened (as
  10676. during an Open command). It then repeatedly gets and handles events
  10677. until the user either confirms the command after choosing a file name or
  10678. aborts the command by clicking Cancel in the dialog. It reports the
  10679. user's reply by filling the fields of the reply record specified by the
  10680. reply parameter, as described above under "Using the Standard File
  10681. Package".
  10682.  
  10683.     The general appearance of the standard SFGetFile dialog box is shown
  10684. in Figure S-5. File names are sorted in order of the ASCII codes of
  10685. their characters, ignoring diacritical marks and mapping lowercase
  10686. characters to their uppercase equivalents. If there are more file names
  10687. than can be displayed at one time, the scroll bar is active; otherwise,
  10688. the scroll bar is inactive.
  10689.  
  10690.     The where parameter specifies the  location of the top left corner
  10691. of the dialog box in global coordinates. The prompt parameter is
  10692. ignored; it's there for historical purposes only.
  10693.  
  10694.     The fileFilter, numTypes, and typeList parameters determine which
  10695. files appear in the dialog box. SFGetFile first looks at numTypes and
  10696. typeList to determine what types of files to display, then it executes
  10697. the function pointed to by fileFilter (if any) to do additional
  10698. filtering on which files to display. File types are discussed in the
  10699. manual THE STRUCTURE OF A MACINTOSH APPLICATION. For example, if the
  10700. applicaiton is concerned only with pictures, you won't want to display
  10701. the names of any text files.
  10702.  
  10703.     Pass -1 for numTypes to display all types of files; otherwise, pass
  10704. the number of file types you want to display, and pas the types
  10705. themselves in typeList. The SFTypeList data type is defined as follows:
  10706.  
  10707.          TYPE SFTypeList = ARRAY [0..3] OF OSTYPE;
  10708.  
  10709. (note)
  10710.        This array is declared for a reasonable maximum number of
  10711.        types (four). If you need to specify more than four
  10712.        types, declare your own array type with the desired
  10713.        number of entries (and use the @ operator to pass a
  10714.        pointer to it).
  10715.  
  10716.     If fileFilter isn't NIL, SFGetFile executes the function it points
  10717. to for each file, to determine whether the file should be displayed.
  10718. The fileFilter function has one parameter and returns a Boolean value.
  10719. For example:
  10720.  
  10721.          FUNCTION MyFileFilter (paramBlock: ParmBlkPtr) : BOOLEAN;
  10722.  
  10723.     SFGetFile passes this function the file information it gets by
  10724. calling the File Manager procedure PBGetFInfo. The function selects
  10725. which files should appear in the dialog by returning FALSE for every
  10726. file that should be shown and TRUE for every file that shouldn't be
  10727. shown.
  10728.  
  10729. (note)
  10730.        As described in the File Manager manual, a flag can be
  10731.        set that tells the Finder not to display a particular
  10732.        file's icon on the desktop; this has no effect on whether
  10733.        SFGetFile will list the file name.
  10734.  
  10735.     If you want to use the standard SFGetFile dialog box, pass NIL for
  10736. dlgHook; otherwise, see the information for advanced programmers below.
  10737.  
  10738.     Like SFPutFile, SFGetFile repeatedly calls the Dialog Manager
  10739. Procedure ModalDialog. When an event involving an enabled dialog item
  10740. occurs, ModalDialog handles the event and returns the item number, and
  10741. SFGetFile responds as follows:
  10742.  
  10743.    - If the Eject or Drive button is clicked, or a disk is inserted,
  10744.      SFGetFile responds as described above under "About the Standard
  10745.      File Package".
  10746.  
  10747.    - If clicking or dragging occurs in the scroll bar, the contents of
  10748.      the dialog box are redrawn accordingly.
  10749.  
  10750.    - If a file name is clicked, it's selected and stored in the fName
  10751.      field of the reply record. (SFGetFile keeps track of whether a
  10752.      file name is currently selected, and makes the Open button
  10753.      inactive if not.)
  10754.  
  10755.    - If the Open button is clickd, SFGetFile returns control to the
  10756.      application with the first field of the reply record set to TRUE.
  10757.  
  10758.    - If a file name is double-clicked, SFGetFile responds as if the
  10759.      user clicked the file name and then the Open button.
  10760.  
  10761.    - If the Cancel button in the dialog is clicked, SFGetFile returns
  10762.      control to the application with the first field of the reply
  10763.      record set to FALSE.
  10764.  
  10765.     If a key (other than a modifier key) is pressed, SFGetFile selects
  10766. the first file name starting with the character typed. If no file name
  10767. starts with that character, it selects the first file name starting
  10768. with a character whose ASCII code is greater than the character typed.
  10769.  
  10770. Advanced programmers:  You can create your own dialog box rather than
  10771. use the  standard SFGetFile dialog. To do this, you must provide your
  10772. own dialog template and store it in your application's resource file
  10773. with the same resource ID that the standard template has in the system
  10774. resource file:
  10775.  
  10776.         CONST getDlgID = -4000;   {SFGetFile dialog template ID}
  10777.  
  10778. (note)
  10779.       THe SFPGetFile procedure, described below, lets you use
  10780.       any resource ID for your nonstandard dialog box.
  10781.  
  10782.  
  10783.     Your dialog template must specify that the dialog window be
  10784. invisible, and your dialog must contain all the standard items, as
  10785. listed below. The appearance and location of these items in your dialog
  10786. may be different. You can make an item "invisible" by giving it a
  10787. display rectangle that's off the screen. The display rectangle for each
  10788. in the standard dialog box is given below. THe rectangle for the
  10789. standard dialog box itself is (0,0,348,136).
  10790.  
  10791.  Item Number    Item                     Standard display rectangle
  10792.     1         Open button                     (152,28,232,46)
  10793.     2         Invisible button                (1152,59,1232,77)
  10794.     3         Cancel button                   (152,90,232,108)
  10795.     4         UserItem for disk name          (248,28,344,46)
  10796.     5         Eject button                    (256,59,336,77)
  10797.     6         Drive button                    (256,90,336,108)
  10798.     7         UserItem for file name list     (12,11,125,125)
  10799.     8         UserItem for scroll bar         (124,11,140,125)
  10800.     9         UserItem for gray line          (244,20,245,116)
  10801.    10         Invisible text (statText)       (1044,20,1145,116)
  10802.  
  10803.     If your dialog has additional items beyond the standard ones, or if
  10804. you want to handle any of the standard items in a nonstandard manner,
  10805. you must write your own dlgHook function and point to it with dlgHook.
  10806. Your dlgHook function should have two parameters and return an integer
  10807. value. For example, this is how it would be declared if it were named
  10808. MyDlg:
  10809.  
  10810.        FUNCTION MyDlg (item: INTEGER; theDialog: DialogPtr) : INTEGER;
  10811.  
  10812.     Immediately after calling ModalDialog, SFGetFile calls you dlgHook
  10813. Function, passing it the item number returned by ModalDialog and a
  10814. pointer to the dialog record describing you dialog box. Using these
  10815. two parameters, your dlgHook function should determine how to handle
  10816. the event. There are predefined constants for the item numbers of
  10817. standard enabled items, as follows:
  10818.  
  10819.     CONST getOpen    = 1;   {Open button}
  10820.           getCancel  = 3;   {Cancel button}
  10821.       getEject   = 5;   {Eject button}
  10822.       getDrive   = 6;   {Drive button}
  10823.       getNmList  = 7;   {userItem for file name list}
  10824.       getScroll  = 8;   {userItem for scroll bar}
  10825.  
  10826.     ModalDIalog also returns "fake" item numbers in the following
  10827. situations, which are detected by its filterProc function:
  10828.  
  10829.    - When a disk-inserted event occurs, it returns 100.
  10830.  
  10831.    - When a key-down event occurs, it returns 1000 plus the ASCII code
  10832.      of the character.
  10833.  
  10834.     After handling the event (or, perhaps, after ignoring it) your
  10835. dlgHook function must return an item number to SFGetFile. If the item
  10836. number is one of those listed above, SFGetFile responds in the standard
  10837. way; otherwise, it does nothing.
  10838. \ SFPGetFile
  10839. 13
  10840. Procedure SFPGetFile (where: Point; prompt: Str255; fileFilter:
  10841.             ProcPtr; numTypes: INTEGER; typeList: SFTypeList; dlgHook:
  10842.         ProcPtr; VAR reply: SFReply; dlgID: INTEGER; filterProc:
  10843.         ProcPtr);
  10844.  
  10845.     SFPGetFile is an alternative to SFGetFile for advanced programmers
  10846. who want to use a nonstandard dialog box. It's the same as  SFGetFile
  10847. except for the two additional parameters dlgID and filterProc.
  10848.  
  10849.     DlgID is the rexource ID of the dialog template to be used instead
  10850. of the standard one (so you can use whatever ID you wish rather than the
  10851. same one as the standard).
  10852.  
  10853.     The filterProc parameter determines how ModalDialog will filter
  10854. events when called by SFPGetFile. If filterProc is NIL, ModalDialog
  10855. does the standard filtering that it does when called by SFGetFile;
  10856. otherwise, filterProc should point to a function for ModalDialog to
  10857. execute after doing the standard filtering. Note, however, that the
  10858. standard filtering will detect key-down events only if the dialog
  10859. template ID is the standard one.
  10860. \ DILoad
  10861. 13
  10862. Procedure DILoad;
  10863.  
  10864.     DILoad reads the Disk Initialization Package, and its associated
  10865. dialog and dialog items, from the system resource file into memory and
  10866. makes them unpurgeaable.
  10867.  
  10868. (note)
  10869.        DIFormat, DIVerify, and DIZero don't need the dialog, so
  10870.        if you use only these routines you can call the Resource
  10871.        Manager function GetResource to read just the package
  10872.        resource into memory (and the Memory Manager procedure
  10873.        HNoPurge to make it unpurgeable).
  10874. \ DIUnload
  10875. 13
  10876. Procedure DIUnload;
  10877.  
  10878.     DIUnload makes the Disk Initialization Package (and its associated
  10879. dialog an dialog items) purgeable.
  10880. \ DIBadMount
  10881. 13
  10882. Function DIBadMount (where: Point; evtMessage: LongInt) : INTEGER;
  10883.  
  10884.     Call DIBadMount when a disk-inserted event occurs if the result code
  10885. in the high-order word of the associated event message indicates an
  10886. error (that is, the result code is other than noErr). Given the event
  10887. message in evtMessage, DIBadMount evaluates the result code and either
  10888. ejects the disk or lets the user initialize and name it. The low-order
  10889. word of the event message contains the drive number. The where
  10890. parameter specifies the location (in global coordinates) of the top
  10891. left corner of the dialog box displayed by DIBadMount.
  10892.  
  10893.     If the result code passed is extFSErr, mFulErr, nsDrvErr, paramErr
  10894. , or volOnLinErr, DIBadMount displays a dialog box that describes the
  10895. problem and asks whether the user wants to initialized the disk. For
  10896. the result code ioErr, the dialog box shown in Figure D-1 is displayed.
  10897. (This happens if the disk is brand new.)  For badMDBErr and noMacDskErr,
  10898. DIBadMount displays a similar dialog box in which the description of
  10899. the problem is "This disk is damaged" and "This is not a Macintosh
  10900. disk", respectively.
  10901.  
  10902. (note)
  10903.        Before presenting the disk initialization dialog,
  10904.        DIBadMount checks whether the drive contains an already
  10905.        mounted volume; if so, it ejects the disk and returns 2
  10906.        as its result. This will happen rarely and may reflect
  10907.        an error in your program (for example, you forgot to call
  10908.        DILoad and the user had to switch to the disk containing
  10909.        the system resource file).
  10910.  
  10911.     If the user responds to the disk initialization dialog by clicking
  10912. the Eject button, DIBadMount ejects the disk and returns 1 as its result
  10913. If the Initialize button is clicked, a box displaying the message
  10914. "Initializing disk..." appears, and DIBadMount attempts to initialize
  10915. the disk. If initialization fails, the disk is ejected and the user is
  10916. informed as shown in Figure D-2; after the user clicks OK, DIBadMount
  10917. returns a negative result code ranging from firstDskErr to lastDskErr,
  10918. indicating that a low-level disk error occurred.
  10919.  
  10920.     If the disk is successfully initialized, the dialog box in Figure D
  10921. appears. After the user names the disk and clicks OK, DIBadMount
  10922. mounts the volume by calling the File Manager function PBMountVol and
  10923. returns PBMountVol's result code (noErr if no error occurs).
  10924.  
  10925.       Result codes
  10926.       ------------
  10927.       noErr                No error
  10928.       extFSErr             External file system
  10929.       mFulErr              Memory full
  10930.       nsDrvErr             No such drive
  10931.       paramErr             Bad drive number
  10932.       volOnLinErr          Volume already on-line
  10933.       firstDskErr          Low-level disk error
  10934.       through lastDskErr
  10935.  
  10936.       Other results
  10937.       -------------
  10938.       1                    User clicked Eject
  10939.       2                    Mounted volume in drive
  10940. \ DIFormat
  10941. 13
  10942. Function DIFormat (drvNum: INTEGER) : OSErr;
  10943.  
  10944.     DILFormat formats the disk in the drive specified by the given drive
  10945. number and returns a result code indicating whether the formatting was
  10946. completed successfully or failed. Formatting a disk consists of
  10947. writing special infromation onto it so that the Disk Driver can read
  10948. from and write to the disk.
  10949.  
  10950.       Result codes
  10951.       ------------
  10952.       noErr               No error
  10953.       firstDskErr         Low-level disk error
  10954. \ DIVerify
  10955. 13
  10956. Function DIVerify (drvNum: INTEGER) : OSErr;
  10957.  
  10958.     DIVerify verifies the format of the disk in the drive specified by
  10959. the given drive number; it reads each bit from the disk and returns a
  10960. result code indicating whether all bits were read successfully or not.
  10961.  
  10962.       Result codes
  10963.       ------------
  10964.       noErr                 No error
  10965.       firstDskErr           Low-level disk error
  10966. \ DIZero
  10967. 13
  10968. Function DIZero (drvNum: INTEGER; volName: Str255) : OSErr;
  10969.  
  10970.     On the unmounted volume in the drive specified by the given drive
  10971. number, DIZero writes the volume information, a block map, and a file
  10972. directory as for a volume with no files; the volName parameter
  10973. specifies the volume name to be included in the volume information.
  10974. This is the last step in initialization (after formatting and
  10975. verifying) and makes any files that are already on the volume
  10976. permanently inaccessible. If the operation fails, DIZero returns a
  10977. result code indicating that a low-level disk error occurred; otherwise,
  10978. it mounts the volume by calling the File Manager function PBMountVol
  10979. and returns PBMountVol's result code (noEr if no error occurs).
  10980.  
  10981.  
  10982.       Result codes
  10983.       ------------
  10984.       noErr                    No error
  10985.       badMDBErr                Bad master directory block
  10986.       extFSErr                 External file system
  10987.       ioErr                    Disk I/O error
  10988.       mFulErr                  Memory full
  10989.       noMacDskErr              Not a Macintosh volume
  10990.       nsDrvErr                 No such drive
  10991.       paramErr                 Bad drive number
  10992.       volOnLinErr              Volume already on-line
  10993.       firstDskErr              Low-level disk error
  10994.       through lastDskErr
  10995. \ InitApplZone
  10996. 14
  10997. Procedure InitApplZone;
  10998.  
  10999.       _________________________________________________________
  11000.  
  11001.       Trap macro            _InitApplZone
  11002.       On exit               D0:  result code (integer)
  11003.  
  11004.       _________________________________________________________
  11005.  
  11006.  
  11007.     InitApplZone initializes the application heap zone and makes it the
  11008. current zone. The contents of any previous application zone are lost;
  11009. all previously existing blocks in that zone are discarded.
  11010. InitApplZone is called by the Segment Loader when starting up an
  11011. application;  you shouldn't normally need to call it.
  11012.  
  11013. (warning)
  11014.        Reinitializing the application zone from within a running
  11015.        program is tricky, since the program's code itself
  11016.        resides in the application zone. To do it safely, the
  11017.        code containing the InitApplZone call cannot be in the
  11018.        application zone.
  11019.  
  11020.     The application zone has an initial size of 6K bytes, and can be
  11021. expanded as needed in 1K increments. Space is initially allocated for
  11022. 64 master pointers; should more be needed later, they will be added 64
  11023. at a time. The zone's grow zone function is set to NIL.
  11024.  
  11025.        Result codes        noErr         No eror
  11026. \ SetApplBase
  11027. 14
  11028. Procedure SetApplBase (startPtr: Ptr);
  11029.  
  11030.             _________________________________________________
  11031.  
  11032.      Trap macro               _SetApplBase
  11033.      On entry                 A0:  startPtr (pointer)
  11034.      On exit                  D0:  result code (integer)
  11035.  
  11036.             _________________________________________________
  11037.  
  11038.  
  11039.     SetApplBase changes the starting address of the application heap
  11040. zone to the address designated by startPtr, and then calls IniApplZone.
  11041. SetApplBase is normally called only by the system itself; you should
  11042. never need to call this procedure.
  11043.  
  11044.     Since the application heap zone begins immediately folowing the end
  11045. of the system zone, changingits starting address has the effect of
  11046. changing the size of the system zone. The system zone can be made
  11047. larger, but never smaller; if startPtr points to an address lower than
  11048. the current end of the system zone, it's ignored and the application
  11049. zone's starting address is left unchanged.
  11050.  
  11051. (warning)
  11052.       Like InitApplZone, SetApplBase is a tricky operation,
  11053.       because the code of the program itself resides in the
  11054.       application heap zone. To do it safely, the code
  11055.       containing the SetApplBase call cannot be in the
  11056.       application zone.
  11057.  
  11058.       Result codes     noErr             No error
  11059. \ InitZone
  11060. 14
  11061. Procedure InitZone (pGrowZone: ProcPtr; cMoreMasters: INTEGER;
  11062.                     limitPtr, startPtr: Ptr);
  11063.  
  11064.  
  11065.        ________________________________________________________
  11066.  
  11067.         Trap macro            _InitZone
  11068.  
  11069.         On entry              A0:  pointer to parameter block
  11070.  
  11071.         Parameter block
  11072.                0      startPtr       pointer
  11073.                4      limitPtr       pointer
  11074.                8      cMoreMasters   integer
  11075.               10      pGrowZone      pointer
  11076.  
  11077.         On exit                D0: result code (integer)
  11078.  
  11079.        ________________________________________________________
  11080.  
  11081.  
  11082.     InitZone creates a new heap zone initializes its header and trailer,
  11083. and makes it the current zone. The startPtr parameter is a pointer to
  11084. the first byte of the new zone; limitPtr points to the first byte of
  11085. the zone trailer. The new zone will occupy memory addresses from
  11086. ORD(startPtr) to ORD(limitPtr)+11.
  11087.  
  11088.     CMoreMasters tells how many master pointers should be allocated at a
  11089. time for the new zone. This number of master pointers are created
  11090. initially; should more be needed later, they will be added in
  11091. increments of this same number. For the system heap zone, this number
  11092. is initially 32; for the application heap zone, it's 64.
  11093.  
  11094.     The pGrowZone parameter is a pointer to the grow zone function for
  11095. the new zone, if any. If you're not defining a grow zone function for
  11096. this zone, pass NIL.
  11097.  
  11098.     The new zone includes a 52-byte header, so its actual usable space
  11099. runs from ORD(startPtr)+52 through ORD(limitPtr)-1. In addition, each
  11100. master pointer occupies four bytes within this usable area. Thus the
  11101. total available space in the zone, in bytes, is initially
  11102.  
  11103.       ORD(limitPtr) - ORD(startPtr) - 52 - 4*cMoreMasters
  11104.  
  11105.     This number must not be less than 0. Note that the amount of
  11106. available space in the zone will decrease as more master pointers are
  11107. allocated.
  11108.  
  11109.       Result codes        noErr                No error
  11110. \ SetApplLimit
  11111. 14
  11112. Procedure SetApplLimit (zoneLimit: Ptr);
  11113.  
  11114.         _________________________________________________
  11115.  
  11116.          Trap macro        _SetApplLimit
  11117.  
  11118.          On entry          A0:  zoneLimit (pointer)
  11119.  
  11120.          On exit           D0:  result code (integer)
  11121.  
  11122.         _________________________________________________
  11123.  
  11124.  
  11125.     SetApplLimit sets the application heap limit, beyond which the
  11126. application heap zone can't be expanded. The actual expansion isn't
  11127. under your program's control, but is done automatically by the Memory
  11128. Manager when necessary to satisfy allocation requests. Only the
  11129. original application zone can be expanded.
  11130.  
  11131.     ZoneLimit  is a limit pointer to a byte in memory beyond which the
  11132. zone will not be allowed to grow. The zone can grow to include the byte
  11133. preceding zoneLimit in memory, but no farther. If the zone already
  11134. extends beyond the specified limit it won't be cut back, but it will be
  11135. prevented from growing any more.
  11136.  
  11137. (warning)
  11138.        Notice that zoneLimit is not a byte count. To limit the
  11139.        application zone to a particular size (say 8Kbytes), you
  11140.        have to write something like
  11141.  
  11142.             SetApplLimit(Ptr(ApplicZone)+8192)
  11143.  
  11144.        The Memory Manager function ApplicZone is explained
  11145.        below.
  11146.  
  11147.  
  11148.             _________________________________________________
  11149.  
  11150.        Assembly-language note:  The global variable ApplLimit contains
  11151.        the application heap limit.
  11152.  
  11153.             _________________________________________________
  11154.  
  11155.  
  11156.        Result codes      noErr           No error
  11157. \ MaxApplZone
  11158. 14
  11159. Procedure MaxApplZone;    [No trap macro]
  11160.  
  11161.     MaxApplZone expands the application heap zone to the application
  11162. heap limit without purging any blocks currently in the zone. If the
  11163. zone already extends to the limit, it won't be changed.
  11164.  
  11165.       Result codes      noErr           No error
  11166. \ MoreMasters
  11167. 14
  11168. Procedure MoreMasters;
  11169.  
  11170.             _________________________________________________
  11171.  
  11172.        Trap macro         _MoreMasters
  11173.  
  11174.             _________________________________________________
  11175.  
  11176.     MoreMasters allocates another block of master pointers in the
  11177. current heap zone. This procedure is usually called very early in an
  11178. application.
  11179.  
  11180.      Result codes
  11181.      ------------
  11182.      noErr             No error
  11183.      memFullErr        Not enough room in zone
  11184. \ GetZone
  11185. 14
  11186. Function GetZone:  THz;
  11187.  
  11188.             _________________________________________________
  11189.  
  11190.       Trap macro             _GetZone
  11191.  
  11192.       On exit                A0:  function result (pointer)
  11193.                              D0:  result code (integer)
  11194.             _________________________________________________
  11195.  
  11196.     GetZone returns a pointer to the curent heap zone.
  11197.  
  11198.             _________________________________________________
  11199.  
  11200.       Assembly-language note:  The global variable TheZone contains a
  11201.       pointer to the current heap zone.
  11202.             _________________________________________________
  11203.  
  11204.       Result codes      noErr          No error
  11205. \ SetZone
  11206. 14
  11207. Procedure SetZone (hz: THz);
  11208.  
  11209.             _________________________________________________
  11210.  
  11211.        Trap macro      _SetZone
  11212.  
  11213.        On entry        A0:  hz (pointer)
  11214.  
  11215.        On exit         D0:  result code (integer)
  11216.             _________________________________________________
  11217.  
  11218.     SetZone sets the current heap zone to the zone pointed to by hz.
  11219.  
  11220.             _________________________________________________
  11221.  
  11222.        Assembly-language note:  You can set the current heap zone by
  11223.        storing a pointer to it in the global variable TheZone.
  11224.             _________________________________________________
  11225.  
  11226.        Result codes          noErr           No error
  11227.  
  11228.  
  11229.  
  11230. \ SystemZone
  11231. 14
  11232. Function SystemZone : THz;       [No trap macro]
  11233.  
  11234.     SystemZone returns a pointer to the system heap zone.
  11235.  
  11236.             _________________________________________________
  11237.  
  11238.        Assembly-language note:  The global variable SysZone contains a
  11239.        pointer to the system heap zone.
  11240.             _________________________________________________
  11241.  
  11242.        Result codes            noErr        No error
  11243. \ ApplicZone
  11244. 14
  11245. Procedure ApplicZone : THz;  [No trap macro]
  11246.  
  11247.     ApplicZone returns a pointer to the original application heap zone.
  11248.  
  11249.             _________________________________________________
  11250.  
  11251.      Assembly-language note:  The global variable ApplZone contains a
  11252.      pointer to the original application heap zone.
  11253.             _________________________________________________
  11254.  
  11255.      Result codes         noErr          No error
  11256. \ NewHandle
  11257. 14
  11258. Function NewHandle (logicalSize: Size) : Handle;
  11259.  
  11260.     __________________________________________________________
  11261.  
  11262. Trap macro       _NewHandle
  11263.                  _NewHandle ,SYS           (applies to system heap)
  11264.                  _NewHandle ,CLEAR         (clears allocated block)
  11265.                  _NewHandle ,SYS,CLEAR     (applies to system heap and
  11266.                                             clears allocated block)
  11267.  
  11268. On entry         D0:  logicalSize (long integer)
  11269.  
  11270. On exit          A0:  function result (handle)
  11271.                  D0:  result code (integer)
  11272.     __________________________________________________________
  11273.  
  11274.     NewHandle attempts to allocate a new relocatable block of
  11275. logicalSize bytes from the current heap zone and then return a handle to
  11276. it. The new block will be unlocked and unpurgeable. If logicalSize bytes
  11277. can't be allocated, NewHandle returns NIL.
  11278.  
  11279.     NewHandle will pursue all available avenues to create a free block
  11280. of the requested size, includinig compacting the heap zone, increasing
  11281. its size, purging blocks from it, and calling its grow zone function, if
  11282. any.
  11283.  
  11284.        Result codes     noErr           No error
  11285.                         memFulErr       Not enough room in zone
  11286. \ DisposHandle
  11287. 14
  11288. Procedure DisposHandle (h: Handle);
  11289.  
  11290.             _________________________________________________
  11291.  
  11292.       Trap macro           _DisposHandle
  11293.  
  11294.       On entry             A0:  h (handle
  11295.  
  11296.       On exit              A0:  0
  11297.                            D0: result code (integer)
  11298.             _________________________________________________
  11299.  
  11300.     DisposHandle releases the memory occupied by the relocatable block
  11301. whose handle is h.
  11302.  
  11303. (warning)
  11304.        After a call to DisposHandle, all handles to the released
  11305.        block become invalid and should not be used again.
  11306.  
  11307.        Result codes     noErr       No error
  11308.                         memWZErr    Attempt to operate on a free block
  11309. \ GetHandleSize
  11310. 14
  11311. Function GetHandleSize (h: Handle) : Size;
  11312.  
  11313.             _________________________________________________
  11314.  
  11315.      Trap macro      _GetHandleSize
  11316.  
  11317.      On entry        A0:  h (handle)
  11318.  
  11319.      On exit         D0:  if >=0, function result (long integer)
  11320.                           if <0, result code (integer)
  11321.             _________________________________________________
  11322.  
  11323.     GetHandleSize returns the logical size, in bytes, of the relocatable
  11324. block whose handle is h. In case of an error, GetHandleSize returns 0.
  11325.  
  11326.             _________________________________________________
  11327.  
  11328.      Assembly-language note:  Recall that the trap dispatcher sets
  11329.      the condition codes before returning from a trap by testing the
  11330.      low-order word of register D0 with a TST.W instruction. Since
  11331.      the block size returned in D0 by _GetHandleSize is a full 32-bit
  11332.      long word, the word-length test sets the condition codes
  11333.      incorrectly in this case. To branch on the contents of D0, use
  11334.      your own TST.L instruction on return from the trap to test the
  11335.      full 32 bits of the register.
  11336.             _________________________________________________
  11337.  
  11338.      Result codes    noErr           No error   [Pascal only]
  11339.                     nilHandleErr     NIL master pointer
  11340.                     memWZErr         Attempt to operate on a free block
  11341. \ SetHandleSize
  11342. 14
  11343. Procedure SetHandleSize (h: Handle; newSize: Size);
  11344.  
  11345.             _________________________________________________
  11346.  
  11347.      Trap macro          _SetHandleSize
  11348.  
  11349.      On entry       A0:  h (handle)
  11350.                     D0:  newSize (long integer)
  11351.  
  11352.      On exit        D0:  result code (integer)
  11353.             _________________________________________________
  11354.  
  11355.     SetHandleSize changes the logical size of the relocatable block
  11356. whose handle is h to newSize bytes.
  11357.  
  11358. (note)
  11359.        Don't attempt to increase the size of a locked block,
  11360.        becausse its unlikely the Memory Manager will be able to
  11361.        do so.
  11362.  
  11363.        Result codes
  11364.  
  11365.        noErr         No error
  11366.        memFullErr    Not enough room to grow
  11367.        nilHandleErr  NIL master pointer
  11368.        memWZErr      Attempt to operate on a free block
  11369. \ HandleZone
  11370. 14
  11371. Function HandleZone (h: Handle) : THz;
  11372.  
  11373.         _________________________________________________
  11374.  
  11375.           Trap macro    _HandleZone
  11376.  
  11377.           On entry      A0: h (handle)
  11378.  
  11379.           On exit       A0:  function result (pointer)
  11380.                         D0:  result code (integer)
  11381.         _________________________________________________
  11382.  
  11383.     HandleZone returns a pointer to the heap zone containing the
  11384. relocatable block whose handle is h.
  11385.  
  11386. (warning)
  11387.         If handle h is empty (points to a NIL master pointer),
  11388.     HandleZone returns a pointer to the current heap zone.
  11389.     In case of an error, the result returned by HandleZone is
  11390.     meaningless and should be ignored.
  11391.  
  11392. Result codes      noErr            No error
  11393.                   memWZErr         Attempt to operate on a free block
  11394. \ RecoverHandle
  11395. 14
  11396. Function RecoverHandle (p:Ptr) : Handle;
  11397.  
  11398.             _________________________________________________
  11399.  
  11400.       Trap macro      _RecoverHandle
  11401.                       _RecoverHandle ,SYS     (applies to system heap)
  11402.  
  11403.       On entry        A0:  p (pointer)
  11404.  
  11405.       On exit         A0:  function result (handle)
  11406.                       D0:  unchanged
  11407.             _________________________________________________
  11408.  
  11409.  
  11410.     RecoverHandle returns a handle to the relocataable block pointed to
  11411. by p.
  11412.  
  11413.             _________________________________________________
  11414.  
  11415.     Assembly-language note:  The trap _RecoverHandle doesn't return
  11416.     a result code in register D0; the previous contents of D0 are
  11417.     preserved unchanged.
  11418.             _________________________________________________
  11419.  
  11420.     Result codes     noErr          No error   [Pascal only]
  11421. \ ReallocHandle
  11422. 14
  11423. Procedure ReallocHandle (h: Handle; logicalSize: Size);
  11424.  
  11425.             _________________________________________________
  11426.  
  11427.     Trap macro         _ReallocHandle
  11428.  
  11429.     On entry           A0:  h (handle)
  11430.                        D0:  logicalSize   (integer)
  11431.  
  11432.     On exit            A0:  original h or 0
  11433.                        D0:  result code  (integer)
  11434.             _________________________________________________
  11435.  
  11436.     ReallocHandle allocates a new relocatable block with a logical size
  11437. of logicalSize bytes. It then updates handle h by setting its master
  11438. pointer to point to the new block. The main use of this procedure is
  11439. to reallocate space for a block that has been purged. Normally h is an
  11440. empty handle, but it need not be:  if it points to an existing block,
  11441. that block is released before the new block is created.
  11442.  
  11443.     In case of an error, no new block is allocated and handle h is left
  11444. unchanged.
  11445.  
  11446.             _________________________________________________
  11447.  
  11448.     Assembly-language note:  On return from ReallocHandle, register
  11449.     A0 contains the original handle h, or 0 if no room could be
  11450.     found for the requested block.
  11451.             _________________________________________________
  11452.  
  11453.     Result codes
  11454.  
  11455.             noErr       Noerror
  11456.             memFullErr  Not enough room in zone
  11457.             memWZErr    Attempt to operate on a free block
  11458.             MemPurErr   Block is locked
  11459. \ NewPtr
  11460. 14
  11461. Function NewPtr (logicalSize: Size) : Ptr;
  11462.  
  11463.             _________________________________________________
  11464.  
  11465.     Trap macro  _NewPtr
  11466.                 _NewPtr ,SYS        (applies to system heap)
  11467.                 _NewPtr ,CLEAR      (clears allocated block)
  11468.                 _NewPtr ,SYS,CLEAR  (applies to system heap and
  11469.                                     clears allocated block)
  11470.  
  11471.     On entry    D0:  logicalSize (long integer)
  11472.  
  11473.     On exit     A0:  function result (pointer)
  11474.                 D0:  result code (integer)
  11475.             _________________________________________________
  11476.  
  11477.     NewPtr attempts to allocate a new nonrelocatable block of
  11478. logicalSize bytes from the current heap zone and then return a pointer
  11479. to it. If logicalSize bytes can't be allocated, NewPtr returns NIL.
  11480.  
  11481.     Newptr will pursue all available avenues to create a free block of
  11482. the requested size, including compacting the heap zone, increasing its
  11483. size, purging blocks from it, and calling its grow zone function, if
  11484. any.
  11485.  
  11486.     Result codes
  11487.  
  11488.             noErr       No error
  11489.             memFullErr  Not enough room in zone
  11490. \ DisposPtr
  11491. 14
  11492. Procedure DisposPtr (p: Ptr);
  11493.  
  11494.           _________________________________________________
  11495.  
  11496.             Trap macro  _DisposPtr
  11497.  
  11498.             On entry    A0:  p (pointer)
  11499.  
  11500.             On exit     A0:  0
  11501.                         D0:  result code (integer)
  11502.           _________________________________________________
  11503.  
  11504.     DisposPtr releases the memory occupied by the nonrelocatable block
  11505. pointed to by p.
  11506.  
  11507. (warning)
  11508.     After a call to DisposPtr, all pointers to the released
  11509.     block become invalid and should not be used again.
  11510.  
  11511.     Result codes
  11512.  
  11513.             noErr       No error
  11514.             memWZErr    Attempt to operated on a free block
  11515. \ GetPtrSize
  11516. 14
  11517. Function GetPtrSize (p: Ptr) : Size;
  11518.  
  11519.     ___________________________________________________________
  11520.  
  11521.     Trap macro  _GetPtrSize
  11522.  
  11523.     On entry    A0:  p (pointer)
  11524.  
  11525.     On exit     D0:  if >=0, function result (long integer)
  11526.                      if <0, result code (integer)
  11527.     ___________________________________________________________
  11528.  
  11529.     GetPtrSize returns the logical size, in bytes, of the nonrelocatable
  11530. block pointed to by p. In case of an error, GetPtrSize returns 0.
  11531.  
  11532.     ___________________________________________________________
  11533.  
  11534.     Assembly-language note:  Recall that the trap dispatcher sets
  11535.     the condition codes before returning from a trap by testing the
  11536.     low-order half of register D0 with a TST.W instruction. Since
  11537.     the block size returned in D0 by _GetPtrSize is a full 32-bit
  11538.     long word, the word-length test sets the condition codes
  11539.     incorrectly in this case. To branch on the contents of D0, use
  11540.     your own TST.L instruction on return from the trap to test the
  11541.     full 32 bits of the register.
  11542.     ___________________________________________________________
  11543.  
  11544.     Result codes
  11545.  
  11546.             noErr       No error   [Pascal only]
  11547.             memWZErr    Attempt to operate on a free block
  11548. \ SetPtrSize
  11549. 14
  11550. Procedure SetPtrSize (p: Ptr; newSize: Size);
  11551.  
  11552.     ___________________________________________________________
  11553.  
  11554.     Trap macro  _SetPtrSize
  11555.  
  11556.     On entry    A0:  p (pointer)
  11557.  
  11558.     On exit     A0:  function result (pointer)
  11559.             D0:  result code (integer)
  11560.     ___________________________________________________________
  11561.  
  11562.     PtrZone returns a pointer to the heap zone containing the
  11563. nonrelocatable block pointed to by p. In case of an error, the result
  11564. returned by PtrZone is meaningless and should be ignored.
  11565.  
  11566.     Result codes
  11567.  
  11568.             noErr       No error
  11569.             memWZErr    Attempt to operate on a free block
  11570. \ FreeMem
  11571. 14
  11572. Function FreeMem : LONGINT;
  11573.  
  11574.         _______________________________________________________
  11575.  
  11576.         Trap macro  _FreeMem
  11577.                     _FreeMem ,SYS   (applies to system heap
  11578.  
  11579.         On exit     D0:  function result (long integer)
  11580.         _______________________________________________________
  11581.  
  11582.     FreeMem returns the total amount of free space in the current heap
  11583. zone, in bytes. Notice that it ususally isn't possible to allocate a
  11584. block of this size, because of fragmentation due to nonrelocatable or
  11585. locked blocks.
  11586.  
  11587.     Result codes
  11588.  
  11589.             noErr   No error
  11590. \ MaxMem
  11591. 14
  11592. Function MaxMem (VAR grow: Size) : Size;
  11593.  
  11594.             _________________________________________________
  11595.  
  11596.     Trap macro  _MaxMem
  11597.                 _MaxMem ,SYS            (applies to system heap)
  11598.  
  11599.     On exit     D0:  function result    (long integer)
  11600.                 A0:  grow               (long integer)
  11601.             _________________________________________________
  11602.  
  11603.     MaxMem compacts the current heap zone and purges all purgeable
  11604. blocks from the zone. It returns as its result the size in bytes of the
  11605. largest contiguous free block in the zone after the compaction. If the
  11606. current zone is the original application heap zone, the variable
  11607. parameter grow is set to the maximum number of bytes by which the zone
  11608. can grow. For any other heap zone, grow is set to 0. MaxMem doesn't
  11609. actually expand the zone or call its grow zone function.
  11610.  
  11611.     Result codes
  11612.  
  11613.             noErr   No error
  11614. \ CompactMem
  11615. 14
  11616. Function CompactMem (cbNeeded: Size) : Size;
  11617.  
  11618.     ___________________________________________________________
  11619.  
  11620.     Trap macro  _CompactMem
  11621.                 _CompactMem ,SYS    (applies to system heap)
  11622.  
  11623.     On entry    D0:  cbNeeded (longinteger)
  11624.  
  11625.     On exit     D0:  function result (long integer)
  11626.     ___________________________________________________________
  11627.  
  11628.     CompactMem compacts the current heap zone by moving relocatable
  11629. blocks forward and collecting free space together until a contiguous
  11630. block of at least cbNeeded free bytes is found or the entire zone is
  11631. compacted; it doesn't purge any purgeable blocks. CompactMem returns
  11632. the size in bytes of the largest contiguous free block remaining. Note
  11633. that it doesn't actually allocate the block.
  11634.  
  11635. (notee)
  11636.     To force a compaction of the entire heap zone, pass
  11637.     maxSize for cbNeeded.
  11638.  
  11639.     Result codes
  11640.  
  11641.         noErr       No error
  11642. \ ResrvMem
  11643. 14
  11644. Function ResrvMem (cbNeeded: Size);
  11645.  
  11646.     ___________________________________________________________
  11647.  
  11648.     Trap macro  _ResrvMem
  11649.                 _ResrvMem ,SYS      (applies to system heap)
  11650.  
  11651.     On entry    D0:  cbNeeded (long integer)
  11652.  
  11653.     On exit     D0:  result code  (integer)
  11654.     ___________________________________________________________
  11655.  
  11656.     ResrvMem creates free space for a block of cbNeeded contiguous bytes
  11657. at the lowest possible position in the current heap zone. It will try
  11658. every available means to place the block as close as possible to the
  11659. beginnig of the zone, including moving other blocks upward, expanding
  11660. the zone, or purging blocks from it. Notice that ResrvMem doesn't
  11661. actually allocate the block.
  11662.  
  11663. (note)
  11664.     When you allocate a relocatable block that you know will
  11665.     be locked for long periods of time, call ResrvMem first.
  11666.     This reserves space for the block near the beginning of
  11667.     the heap zone, where it will interfere with compaction as
  11668.     little as possible. It isn't necessary to call ResrvMem
  11669.     for a nonrelocatable block; NewPtr calls it
  11670.     automatically.
  11671.  
  11672.     Result codes
  11673.  
  11674.             noErr       No error
  11675.             memFullErr  Not enough room in zone
  11676. \ PurgeMem
  11677. 14
  11678. Procedure PurgeMem (cbNeeded: Size);
  11679.  
  11680.     ___________________________________________________________
  11681.  
  11682.     Trap macro  _PurgeMem
  11683.                 _PurgeMEM ,SYS  (applies to system heap)
  11684.  
  11685.     On entry    D0:  cbNeeded (long integer)
  11686.  
  11687.     On exit     D0:  result code (integer)
  11688.     ___________________________________________________________
  11689.  
  11690.     PurgeMem sequentially purges blocks from the current heap zone until
  11691. a contiguous block of at least cbNeeded free bytes is created or the
  11692. entire zone is purged; it doesn't compact the heap zone. Only
  11693. relocatable, unlocked, purgeable blocks can be purged. Notice that
  11694. PurgeMem doesn't actually allocate the block.
  11695.  
  11696. (note)
  11697.     To force a purge of the entire heap zone, pass maxSize
  11698.     for cbNeeded.
  11699.  
  11700.     Result codes
  11701.  
  11702.             noErr       No error
  11703.             memFullErr  Not enough room in zone
  11704. \ EmptyHandle
  11705. 14
  11706. Procedure EmptyHandle (h: Handle);
  11707.  
  11708.     ___________________________________________________________
  11709.  
  11710.     TRap macro  _EmptyHandle
  11711.  
  11712.     On entry    A0:  h (handle)
  11713.  
  11714.     On exit     A0:  h (handle)
  11715.                 D0:  result code (integer)
  11716.     ___________________________________________________________
  11717.  
  11718.     EmptyHandle purges the relocatable block whose handle is h from its
  11719. heap zone and sets its master pointer to NIL (making it an empty
  11720. handle). If h is already empty, EmptyHandle does nothing.
  11721.  
  11722. (note)
  11723.     Since the space occupied by the block's master pointer
  11724.     itself remains allocated, all handles pointing to it
  11725.     remain valid but empty. When you later reallocate space
  11726.     for the block with ReallocHandle, the master pointer will
  11727.     be updated, causing all existing handles to point
  11728.     correctly to the new block.
  11729.  
  11730.     The block whose handle is h must be unlocked, but need not be
  11731. purgeable.
  11732.  
  11733.     Result codes
  11734.  
  11735.             noErr       No error
  11736.             memWZErr    Attempt to operate on a free block
  11737.             memPurErr   Block is locked
  11738. \ HLock
  11739. 14
  11740. Procedure HLock (h: Handle);
  11741.  
  11742.     ___________________________________________________________
  11743.  
  11744.     Trap macro  _HLock
  11745.  
  11746.     On entry    A0:  h (handle)
  11747.  
  11748.     On exit     D0:  result code (integer)
  11749.     ___________________________________________________________
  11750.  
  11751.     HLock locks a relocatable block, preventing it from being moved
  11752. within its heap zone. If the block is already locked, HLock does
  11753. nothing.
  11754.  
  11755.     ___________________________________________________________
  11756.  
  11757.     Assembly-language note:  Changing the value of the block's
  11758.     master pointer's lock bit with a BSET instruction is faster than
  11759.     HLock. However, HLock may eventually perform additional tasks.
  11760.     ___________________________________________________________
  11761.  
  11762.     Result codes
  11763.  
  11764.             noErr       No error
  11765.             nilHandleErr    NIL master pointer
  11766.             memWZErr    Attempt to opetate on a free block
  11767. \ HUnlock
  11768. 14
  11769. Procedure HUnlock (h: Handle);
  11770.  
  11771.     ___________________________________________________________
  11772.  
  11773.     Trap macro  _HUnlock
  11774.  
  11775.     On entry    A0:  h (handle)
  11776.  
  11777.     On exit     D0:  result code (integer)
  11778.     ___________________________________________________________
  11779.  
  11780.     HUnlock unlocks a relocatable block, allowing it to be moved within
  11781. its heap zone. If the block is already unlocked, HUnlock does nothing.
  11782.  
  11783.     ___________________________________________________________
  11784.  
  11785.     Assembly-language note:  Changing the value of the block's
  11786.     master pointer's lock bit with a BCLR instruction is faster than
  11787.     HUnlock. However, HUnlock may eventually perform additional
  11788.     tasks.
  11789.     ___________________________________________________________
  11790.  
  11791.     Result codes
  11792.  
  11793.             noErr           No error
  11794.             nilHandleErr    NIL master pointer
  11795.             memWZErr        Attempt to operate on a fre block
  11796. \ HPurge
  11797. 14
  11798. Procedure HPurge (h: Handle);
  11799.  
  11800.     ___________________________________________________________
  11801.  
  11802.     Trap macro  _HPurge
  11803.  
  11804.     On entry    A0:  h (handle)
  11805.  
  11806.     On exit     D0:  result code (integer)
  11807.     ___________________________________________________________
  11808.  
  11809.     HPurge marks a relocatable block as purgeable. If the block is
  11810. already purgeable, HPurge does nothing.
  11811.  
  11812.     Result codes
  11813.  
  11814.             noErr       No error
  11815.             nilHandleErr    NIL master pointer
  11816.             memWZErr    Attempt to operate on a free block
  11817. \ HNoPurge
  11818. 14
  11819. Procedure HNoPurge (h: Handle);
  11820.  
  11821.     ___________________________________________________________
  11822.     Trap macro  _HNoPurge
  11823.  
  11824.     On entry    A0:  h (handle)
  11825.  
  11826.     On exit     D0:  result code (integer)
  11827.     ___________________________________________________________
  11828.  
  11829.     HNoPurge marks a relocatable block as unpurgeable. If the block is
  11830. already unprugeable, HNoPurge does nothing.
  11831.  
  11832.     Result codes
  11833.  
  11834.             noErr           No error
  11835.             nilHandleErr    NIL master pointerr
  11836.             memWZErr        Attempt to operate on a free block
  11837. \ SetGrowZone
  11838. 14
  11839. Procedure SetGrowZone (growZone: ProcPtr);
  11840.  
  11841.     ___________________________________________________________
  11842.  
  11843.     Trap macro  _SetGrowZone
  11844.  
  11845.     On entry    A0:  growZone (pointer)
  11846.  
  11847.     On exit     D0:  result code (integer)
  11848.     ___________________________________________________________
  11849.  
  11850.     SetGrowZone sets the current heap fzone's grow zone function as
  11851. designated by the growZone parameter. A NIL parameter value removes
  11852. any grow zone function the zone may previously have had.
  11853.  
  11854. (note)
  11855.     If yokur program presses the limits of the available heap
  11856.     space, it's a good idea to have a grow zone function of
  11857.     some sort. At the very least, the grow zone function
  11858.     should detect when the Memory Manager is about to run out
  11859.     of space at a critical time (see GZCritical, below) and
  11860.     take some graceful action--such as displaying an alert
  11861.     box with the message "Out of memory"--instead of just
  11862.     failing unpredictably.
  11863.  
  11864.     The Memory Manager calls the grow zone function as a last resort
  11865. when trying to allocate space, if it has failed to create a block of the
  11866. needed size after compacting the zone, increasing its size (in the case
  11867. of the origianal application zone), or purging blocks from it. Memory
  11868. Manager routines that may cause the grow zone function to be called are
  11869. NewHandle, NewPtr, SetHandleSize, SetPtrSize, ReallocHandle, and
  11870. ResrvMem.
  11871.  
  11872. The grow zone function should be of the form
  11873.  
  11874.     FUNCTION MyGrowZone (cbNeeded: Size) : Size;
  11875.  
  11876.     The cbNeeded parameter gives the physical size of the needed block
  11877. in bytes, including the block header. The grow zone function should
  11878. attempt to create a free block of at least this size. It should return
  11879. a nonzero number if it's abale to allocate some memory, or 0 if it's not
  11880. able to allocate any.
  11881.  
  11882.     If the grow zone function returns 0, the Memory Manager will give up
  11883. trying to allocate the needed block and will signal failure with the
  11884. result code memFullErr. Otherwise it will compact the heap zone and
  11885. try again to allocate the block. If still unsuccessful, it will
  11886. continue to call the grow zone function repeatedly, compacting the zone
  11887. again after each call, until it either succeeds in allocating the
  11888. needed block or receives a zero result and gives up.
  11889.  
  11890.     The usual way for the grow zone function to free more space is to
  11891. call EmptyHandle to purge blocks that were previously marked
  11892. unpurgeable. Another possibility is to unlock blocks that were
  11893. previously locked.
  11894.  
  11895. (note)
  11896.     Although just unlocking blocks doesn't actually free any
  11897.     additional space in the zone, the grow zone function
  11898.     should still return a nonzero result in this case. This
  11899.     signals the Memory Manager to compact the heap and try
  11900.     again to allocate the needed block.
  11901.  
  11902. (warning)
  11903.     Depending on the circumstances in which the grow zone
  11904.     function is called, there may be particular blocks within
  11905.     the heap zone that must not be purged or released. For
  11906.     instance, if your program is attempting to increase the
  11907.     size of a relocatable block with SetHandleSize, it would
  11908.     be disastrous to release the block being expanded. To
  11909.     deal with such cases safely, it's essential to understand
  11910.     the use of the functions GZCritical and GZSaveHnd (see
  11911.     below).
  11912.  
  11913. (warning)
  11914.     Whenever you call the Resource Manager with
  11915.     SetResPurge(TRUE), it installs its own grow zone function
  11916.     into the application heap zone. The Resource Manager's
  11917.     grow zone function automatically writes to the disk all
  11918.     changed resources before they're purged. If you install
  11919.     your own grow zone function into the application heap
  11920.     zone, you shouldn't call SetResPurge(TRUE).
  11921.  
  11922.     Result codes
  11923.  
  11924.             noErr   No error
  11925. \ GZCritical
  11926. 14
  11927. Function GZCritical : BOOLEAN;    [No trap macro]
  11928.  
  11929.     GZCritical retruns TRUE if the Memory Manager critically needs
  11930. space-- for example, to create a new relocatable or nonrelocatable block
  11931. or to reallocate a handle. It returns FALSE in less critical cases,
  11932. such as ResrvMem trying to reserve space as low as possible in the heap
  11933. zone or SetHandleSize trying to increase the size of a relocatable
  11934. block. GZCritical doesn't affect the value returned by MemError.
  11935.  
  11936. (warning)
  11937.     If you're writing a grow zone function in Pascal, you
  11938.     should always call GZCritical and proceed only if the
  11939.     result is TRUE. All the information you need to handle
  11940.     the critical cases safely is the value of GZSaveHnd (see
  11941.     below). The noncritical cases require additional
  11942.     information that isn't available from Pascal, so your
  11943.     grow zone function should just return 0 and not attempt
  11944.     to free any space.
  11945. \ GZSaveHnd
  11946. 14
  11947. Function GZSaveHnd : Handle;   [No trap macro]
  11948.  
  11949.     GZSave Hnd retruns a handle to a relocatable block that mustn't be
  11950. purged or released by the grow zone function, or NIL if there is no
  11951. such block. For example, during a SetHandleSize call, the handle being
  11952. changed mustn't be purged. The grow zone function will be safe if it
  11953. avoids purging or releasing this block, provided that the grow zone
  11954. call was critical. To handle noncritical cases safely, further
  11955. information is needed that isn't available from Pascal. GZSaveHnd
  11956. doesn't affect the value returned by MemError.
  11957. \ BlockMove
  11958. 14
  11959. Procedure BlockMove (sourcePtr,destPtr: Ptr; byteCount: Size);
  11960.  
  11961.  
  11962.     ___________________________________________________________
  11963.  
  11964.     Trap macro  _BlockMove
  11965.  
  11966.     On entry    A0:  sourcePtr (pointer)
  11967.                 A1:  destPtr (pointer)
  11968.                 D0:  byteCount (long integer)
  11969.  
  11970.     On exit     D0:  result code (integer)
  11971.     ___________________________________________________________
  11972.  
  11973.     BlockMove moves a block of byteCount consecutive bytes from the
  11974. address designated by sourcePtr to that designated by destPtr. No
  11975. pointers are updated.
  11976.  
  11977.     Result codes
  11978.  
  11979.             noErr   No error
  11980. \ TopMem
  11981. 14
  11982. Function TopMem : Ptr;   [No trap macro]
  11983.  
  11984.     TopMem returns a pointer to the address following the last byte of
  11985. RAM.
  11986.  
  11987.             _________________________________________________
  11988.  
  11989.     Assembly-language note:  To get a pointer to the end of RAM from
  11990.     assembly language, use the global variable MemTop.
  11991.             _________________________________________________
  11992.  
  11993.     Result codes
  11994.  
  11995.             noErr   No error
  11996. \ MemError
  11997. 14
  11998. Function MemError : OSErr;   [No trap macro]
  11999.  
  12000.     MemError returns the result code produced by the last Memory Manager
  12001. routine called. (OSErr is an Operating System Utility data type
  12002. declared as INTEGER.)
  12003. \MaxBlock
  12004. 14
  12005. Function MaxBlock : LONGINT;
  12006.     ______________________________________________________________
  12007.  
  12008.     Trap macro  _MaxBlock
  12009.                 _MaxBlock ,SYS  (applies to system heap)
  12010.  
  12011.     On exit     D0:  function result (word)
  12012.     ______________________________________________________________
  12013.     MaxBlock returns the maximum contiguous space in bytes that could be
  12014. obtained by compacting the current zone (without actually doing
  12015. the compaction).
  12016. \PurgeSpace
  12017. 14
  12018. Procedure PurgeSpace (VAR total,contig: LONGINT);
  12019.     ______________________________________________________________
  12020.  
  12021.     Trap macro  _PurgeSpace
  12022.                 _PurgeSpace ,SYS    (applies to system heap)
  12023.  
  12024.     On exit     A0:  contig (long word)
  12025.                 D0:  total (long word)
  12026.     ______________________________________________________________
  12027.     PurgeSpace returns in total the total amount of space in bytes that
  12028. could be obtained by a general purge (without actually doing
  12029. the purge); this amount includes space that is already free.
  12030. The maximum contiguous space in bytes (including already free space)
  12031. that could be obtained by a purge is returned in contig.
  12032. \StackSpace
  12033. 14
  12034. Function StackSpace : LONGINT;
  12035.     ______________________________________________________________
  12036.  
  12037.     Trap macro  _StackSpace
  12038.  
  12039.     On exit     D0:  function result (word)
  12040.     ______________________________________________________________
  12041.     StackSpace returns the current amount of stack space between the
  12042. current stack pointer and the application heap (at the instant
  12043. of return from the trap).
  12044. \NewEmptyHandle
  12045. 14
  12046. Function NewEmptyHandle : Handle;
  12047.     ______________________________________________________________
  12048.  
  12049.     Trap macro  _NewEmptyHandle
  12050.                 _NewEmptyHandle ,SYS    (applies to system heap)
  12051.  
  12052.     On exit     A0:  function result (handle)
  12053.                 D0:  result code (word)
  12054.     ______________________________________________________________
  12055.  
  12056.     NewEmptyHandle is similar in function to NewHandle except that it
  12057. does not allocate any space; the handle returned is empty (in
  12058. other words, it points to a NIL master pointer). NewEmptyHandle
  12059. is used extensively by the Resource Manager; you may not need to use it.
  12060. \HSetRBit
  12061. 14
  12062. Procedure HSetRBit (h: Handle);
  12063.     ______________________________________________________________
  12064.  
  12065.     Trap macro  _HSetRBit
  12066.  
  12067.     On entry    A0:  h (handle)
  12068.  
  12069.     On exit     D0:  result code (word)
  12070.     ______________________________________________________________
  12071.  
  12072.     HSetRBit sets the resource flag of a relocatable block’s master
  12073. pointer.
  12074. \HClrRBit
  12075. 14
  12076. Procedure HClrRBit (h: Handle);
  12077.     ______________________________________________________________
  12078.  
  12079.     Trap macro  _HClrRBit
  12080.  
  12081.     On entry    A0:  h (handle)
  12082.  
  12083.     On exit     D0:  result code (word)
  12084.     ______________________________________________________________
  12085.     HClrRBit clears the resource flag of a relocatable block’s master
  12086. pointer.
  12087. \HGetState
  12088. 14
  12089. Function HGetState (h: Handle) : SignedByte;
  12090.     ______________________________________________________________
  12091.  
  12092.     Trap macro  _HGetState
  12093.  
  12094.     On entry    A0:  h (handle)
  12095.  
  12096.     On exit     D0:  flags (byte)
  12097.     ______________________________________________________________
  12098.     HGetState returns the byte that contains the flags of the master
  12099. pointer for the given handle; it’s used in conjunction with HSetState
  12100. to save and restore the state of the flags contained in this byte.
  12101. You can save this byte, change the state of any of the flags (using
  12102. the routines described above), and then restore their original state
  12103. by passing the byte back to the HSetState procedure (described below).
  12104. \HSetState
  12105. 14
  12106. Procedure HSetState (h: Handle; flags: SignedByte);
  12107.     ______________________________________________________________
  12108.  
  12109.     Trap macro  _HSetState
  12110.  
  12111.     On entry    A0:  h (handle)
  12112.                 D0:  flags (byte)
  12113.  
  12114.     On exit     D0:  result code (word)
  12115.     ______________________________________________________________
  12116.  
  12117.     HSetState is used in conjunction with HGetState; it sets the byte
  12118. that contains the flags of the master pointer for the given handle
  12119. to the byte specified by flags.
  12120. \ UnloadSeg
  12121. 15
  12122. Procedure UnloadSeg (routineAddr: Ptr);
  12123.  
  12124.     UnloadSeg unloads a segment, making it relocatable and purgeable;
  12125. routineAddr is the address of any externally referenced routine in the
  12126. segment. The segment won't actually be purged until the memory it
  12127. occupies is needed. If the segment is purged, the Segment Loader will
  12128. reload it the next time one of the routines in it is called.
  12129. \ CountAppFiles
  12130. 15
  12131. Procedure COuntAppFiles (VAR message:  INTEGER; VAR count: INTEGER);
  12132.  
  12133.     CountAppFiles deciphers the Finder information passed to your
  12134. application, and returns information about the documents that were
  12135. selected when your application was started up. It returns the number
  12136. of selected documents in the count parameter, and a number in the
  12137. message parameter that indicates whether the documents are to be opened
  12138. or printed:
  12139.  
  12140.     CONST appOpen  = 0;   {open the document(s)}
  12141.           appPrint = 1;   {print the document(s)}
  12142. \ GetAppFiles
  12143. 15
  12144. Procedure GetAppFiles (index: INTEGER; VAR theFile: AppFile);
  12145.  
  12146.     GetAppFiles returns information about a document that was selected
  12147. when your application was started up (as listed in the Finder
  12148. information). The index parameter indicates the file for which
  12149. information should be returned; it must be between 1 and the number
  12150. returned by CountAppFiles, inclusive. The information is returned in
  12151. the following data structure:
  12152.  
  12153.     TYPE AppFile = RECORD
  12154.             vRefNum: INTEGER;  {volume reference number}
  12155.             fType:   OSType;   {file type}
  12156.             versNum: INTEGER;  {version number}
  12157.             fName:   Str255;   {file name}
  12158.           END;
  12159.  
  12160.     Volume reference number, file type, version number, and file name
  12161. are discussed in the File Manager manual.
  12162. \ ClrAppFiles
  12163. 15
  12164. Procedure ClrAppFiles (index: INTEGER);
  12165.  
  12166.     ClrAppFiles changes the Finder information passed to your aplication
  12167. about the specified file such that the Finder knows you've processed
  12168. the file. The index parameter must be between 1 and the number
  12169. returned by CountAppFiles, inclusive. You should call ClrAppFiles for
  12170. every document your application opens or prints, so that the
  12171. information returned by CountAppFiles and GetAppFiles is always
  12172. correct. (ClrAppFiles sets the file type in the Finder information to
  12173. 0.)
  12174. \ GetAppParms
  12175. 15
  12176. Procedure GetAppParms (VAR apName: Str255; VAR apRefNum: INTEGER;
  12177.         VAR apParam: Handle);
  12178.  
  12179.     GetAppParms returns information about the current application. It
  12180. returns the application name in apName and the reference number for the
  12181. application's resource file in apRefNum. A handle to the Finder
  12182. information is returned in apParam, but the Finder information is more
  12183. easily accessed with the GetAppFiles call.
  12184. \ ExitToShell
  12185. 15
  12186. Procedure ExitToShell;
  12187.  
  12188.     ExitToShell provides an exit from an application by starting up the
  12189. Finder (after releasing the entire application heap).
  12190. \ Chain
  12191. 15
  12192. Chain procedure
  12193.     Trap Macro    _Chain
  12194.  
  12195.     On entry      (A0): Pointer to application's file name.
  12196.                  4(A0): Configuration of sound and screen buffer (word).
  12197.  
  12198.     Chain starts up an application without doing anything to the application Heap so the current application can let another application take over while still keeping its data around in the heap.
  12199.  
  12200.     Chain also configures memory for the sound and screen buffer. The
  12201. value you pass in 4(A0) determines which sound and screen buffers are
  12202. allocated:
  12203.     • if you pass 0 in 4(A0), yu get the main sound and screen buffers;
  12204.       in this case, you have the largest amount of memory available to
  12205.       your application.
  12206.     • any positive value in 4(A0) causes the alternate sound buffer and
  12207.       main screen buffer to be allocated.
  12208.     • any positive value in 4(A0) causes the alternate sound buffer and
  12209.       alternate screen buffer to be allocated.
  12210.  
  12211.    Warning: The sound buffers and alternate screen buffer are not sup-
  12212.    ported on the Macintosh XL, and the alternate sound and screen buffers
  12213.    may not be supported in future versions of the Macintosh.
  12214.  
  12215.    Note: You can get the most recent value passed in 4(A0) to the chain
  12216.    procedure from the global variable CurPageOption.
  12217.  
  12218.     Chain closes the resource file for any previous application and opens
  12219. the resource file for the application being started; Call DetachResource
  12220. for any resources that you still wish to access.
  12221. \ Launch
  12222. 15
  12223. Procedure Launch
  12224.  
  12225.     Trap Macro    _Launch
  12226.     On Entry      (A0): Pointer to appl file's name.
  12227.                  4(A0): configuration of sound and screen buffers (word).
  12228.  
  12229.     Launch is called by the Finder to start up an application and will rarely need to be called by the application itself. It's the same as the Chain procedure except that it frees the storage occupied by the application Heap and restores the heap to its original size.
  12230.  
  12231.    Note: Launch preserves a special handle in the application Heap which
  12232.    is used for preserving the Desk Scrap between applications.
  12233. \ GetOSEvent
  12234. 16
  12235. Function GetOSEvent (eventMask: INTEGER; VAR theEvent: EventRecord) :
  12236.                         BOOLEAN;
  12237.  
  12238.     ____________________________________________________________
  12239.  
  12240.     Trap macro  _GetOSEvent
  12241.  
  12242.     On entry    A0:  pointer to event record theEvent
  12243.                 D0:  eventMask (word)
  12244.  
  12245.     On exit     D0:  0 if non-null event returned, or
  12246.                  -1 if null event returned (byte)
  12247.     ____________________________________________________________
  12248.  
  12249.     GEtOSEvent returns the next available event of a specified type or
  12250. types and removes it from the event queue. The event is returned as
  12251. the value of the parameter theEvent. The eventMask parameter specifies
  12252. which event types are of interest. GetOSEvent will return the next
  12253. available event of any type designated by the mask. If no event of any
  12254. of the designated types is available, GetOSEvent returns a null event
  12255. and a function result of FALSE; otherwise it returns TRUE.
  12256. \ OSEventAvail
  12257. 16
  12258. Function OSEventAvail (eventMask: INTEGER; VAR theEvent: EventRecord) :
  12259.                         BOOLEAN;
  12260.  
  12261.     __________________________________________________________________
  12262.  
  12263.     Trap macro  _OSEventAvail
  12264.  
  12265.     On entry    A0:  pointer to event record theEvent
  12266.                 D0:  eventMask (word)
  12267.  
  12268.     On exit     D0:  0 if not-null event returned, or
  12269.                     -1 if null event returned (byte)
  12270.     __________________________________________________________________
  12271.  
  12272.     OSEventAvail works exactly the same as GetOSEvent (above) except
  12273. that it doesn't remove the event from the event queue.
  12274.  
  12275. (note)
  12276.     An event returned by OSEventAvail will not be accessible
  12277.     later if in the meantime the queue becomes full and the
  12278.     event is discarded from it; since the events discarded
  12279.     are always the oldest ones in the queue, however, this
  12280.     will happen only in an unusually busy environment.
  12281. \ SetEventMask
  12282. 16
  12283. Procedure SetEventMask (theMask: INTEGER);  [No trap macro]
  12284.  
  12285.     SetEventMask sets the system event mask to the specified event mask.
  12286. The Operating System Event Manager will post only those event types
  12287. that correspond to bits set in the mask. (As usual, it will not post
  12288. activate and update events, which are generated by the Window Manager
  12289. and not stored in the event queue.)  The system event mask is initially
  12290. set to post all except key-up events.
  12291.  
  12292. (warning)
  12293.     Because desk accessories may rely on receiving certain
  12294.     types of events, your application shouldn't set the
  12295.     system event mask to prevent any additional types
  12296.     (besides key-up) from being posted. You should use
  12297.     SetEventMask only to enable key-up events in the unusual
  12298.     case that your application needs to respond to them.
  12299. \ GetEvQHdr
  12300. 16
  12301. Function GetEvQHdr : QHdrPtr;  [No trap macro]
  12302.  
  12303.     GetEvQHdr retruns a pointer to the event queue.
  12304. \ PPostEvent
  12305. 16
  12306. Function PPostEvent (eventCode: INTEGER; eventMsg: LONGINT;
  12307.                         VAR qEl: EvQEl) : OSErr);
  12308.     ____________________________________________________________
  12309.  
  12310.         Trap macro  _PPostEvent
  12311.  
  12312.         On entry    A0:  eventCode (word)
  12313.                     D0:  eventMsg (long word)
  12314.  
  12315.         On exit     A0:  pointer to event queue entry
  12316.     ____________________________________________________________
  12317.     PPostEvent is identical to PostEvent except that it returns a
  12318. pointer to the created queue entry.
  12319. \ FlushEvents
  12320. 16
  12321. Procedure FlushEvents(eventMask, stopMask: Integer);
  12322.  
  12323.     ____________________________________________________________
  12324.  
  12325.         Trap macro  _FlushEvents
  12326.  
  12327.         On entry    D0:  low-order word: eventMask
  12328.                          high-order word: stopMask
  12329.  
  12330.         On exit     D0:  0 or event code (word).
  12331.     ____________________________________________________________
  12332.  
  12333.     FlushEvents removes events from the event queue as specified by the given event masks. It removes all events of the type or types specified by EventMask, up to but not including the first event of any type specified by StopMask; if the event queue doesn't contain any events of the type specified by eventMask, it does nothing. To remove all events specified by EventMask, use a StopMask value of 0.
  12334.  
  12335.     At the beginning of your application, it's usually a good idea to call FlushEvents (EveryEvent, 0) to empty the event queue of any stray events that may have been left lying around, such as unprocessed keystrokes typed to the Finder.
  12336.  
  12337.     ____________________________________________________________
  12338.       Assembly-language note: On exit from this routine, D0
  12339.       contains 0 if all events were removed form the queue, or,
  12340.       if not, an event code specifying the type of the event
  12341.       that caused the removal process to stop.
  12342.     ____________________________________________________________
  12343. \ GetVInfo
  12344. 17
  12345. Function GetVInfo (drvNum: INTEGER; volName: StringPtr;
  12346.                   VAR vRefNum: INTEGER; VAR freeBytes: LONGINT)
  12347.                   : OSErr;
  12348.  
  12349.     GetVInfo returns the name, reference number, and available space
  12350. (in bytes), in volName, vRefNum, and freeBytes, for the volume in
  12351. the drive specified by drvNum.
  12352.  
  12353. Result codes    noErr     No error
  12354.                 nsvErr    No default volume
  12355.                 paramErr  Bad drive number
  12356. \ GetVRefNum
  12357. 17
  12358. Function GetVRefNum (pathRefNum: INTEGER; VAR vRefNum: INTEGER)
  12359.                     : OSErr;
  12360.  
  12361.     Given a path reference number in pathRefNum, GetVRefNum returns
  12362. the volume reference number in vRefNum.
  12363.  
  12364. Result codes    noErr       No error
  12365.                 rfNumErr    Bad reference number
  12366. \ GetVol
  12367. 17
  12368. Function GetVol (volName: StringPtr; VAR vRefNum: INTEGER)
  12369.                 : OSErr;
  12370.  
  12371.     GetVol returns the name of the default volume in volName and its
  12372. volume reference number in vRefNum.
  12373.  
  12374. Result codes    noErr   No error
  12375.                 nsvErr  No such volume
  12376. \ SetVol
  12377. 17
  12378. Function SetVol (volName: StringPtr; vRefNum: INTEGER)
  12379.                 : OSErr;
  12380.  
  12381.     SetVol sets the default volume to the mounted volume specified
  12382. by volName or vRefNum.
  12383.  
  12384. Result codes    noErr       No error
  12385.                 bdNamErr    Bad volume name
  12386.                 nsvErr      No such volume
  12387.                 paramErr    No default volume
  12388. \ FlushVol
  12389. 17
  12390. Function FlushVol (volName: StringPtr; vRefNum: INTEGER)
  12391.                     : OSErr;
  12392.  
  12393.     On the volume specified by volName or vRefNum, FlushVol writes
  12394. the contents of the associated volume buffer and descriptive
  12395. information about the volume (if they’ve changed since the last
  12396. time FlushVol was called).
  12397.  
  12398. Result codes    noErr       No error
  12399.                 bdNamErr    Bad volume name
  12400.                 extFSErr    External file system
  12401.                 ioErr       I/O error
  12402.                 nsDrvErr    No such drive
  12403.                 nsvErr      No such volume
  12404.                 paramErr    No default volume
  12405. \ UnmountVol
  12406. 17
  12407. Function UnmountVol (volName: StringPtr; vRefNum: INTEGER)
  12408.                     : OSErr;
  12409.  
  12410.     UnmountVol unmounts the volume specified by volName or vRefNum,
  12411. by calling FlushVol to flush the volume buffer, closing all
  12412. open files on the volume, and releasing the memory used for the volume.
  12413.  
  12414. Warning:  Don’t unmount the startup volume.
  12415.  
  12416. Result codes    noErr       No error
  12417.                 bdNamErr    Bad volume name
  12418.                 extFSErr    External file system
  12419.                 ioErr       I/O error
  12420.                 nsDrvErr    No such drive
  12421.                 nsvErr      No such volume
  12422.                 paramErr    No default volume
  12423. \ Eject
  12424. 17
  12425. Function Eject (volName: StringPtr; vRefNum: INTEGER)
  12426.                 : OSErr;
  12427.  
  12428.     Eject flushes the volume specified by volName or vRefNum,
  12429. places it off-line, and then ejects the volume.
  12430.  
  12431. Result codes    noErr       No error
  12432.                 bdNamErr    Bad volume name
  12433.                 extFSErr    External file system
  12434.                 ioErr       I/O error
  12435.                 nsDrvErr    No such drive
  12436.                 nsvErr      No such volume
  12437.                 paramErr    No default volume
  12438. \ Create
  12439. 17
  12440. Function Create (fileName: Str255; vRefNum: INTEGER; creator: OSType;
  12441.                 fileType: OSType) : OSErr;
  12442.  
  12443.     Create creates a new file (both forks) with the specified name,
  12444. file type, and creator on the specified volume. (File type and
  12445. creator are discussed in the Finder Interface chapter.)
  12446. The new file is unlocked and empty. The date and time of its
  12447. creation and last modification are set to the current date and time.
  12448.  
  12449. Result codes    noErr       No error
  12450.                 bdNamErr    Bad file name
  12451.                 dupFNErr    Duplicate file name and version
  12452.                 dirFulErr   File directory full
  12453.                 extFSErr    External file system
  12454.                 ioErr       I/O error
  12455.                 nsvErr      No such volume
  12456.                 vLckdErr    Software volume lock
  12457.                 wPrErr      Hardware volume lock
  12458. \ FSOpen
  12459. 17
  12460. Function FSOpen (fileName: Str255; vRefNum: INTEGER; VAR refNum: INTEGER)
  12461.                 : OSErr;
  12462.  
  12463.     FSOpen creates an access path to the file having the name fileName
  12464. on the volume specified by vRefNum. A path reference number is returned
  12465. in refNum. The access path’s read/write permission is set to whatever
  12466. the file’s open permission allows.
  12467.  
  12468. Note:  There’s no guarantee that any bytes have been written until
  12469.        FlushVol is called.
  12470.  
  12471. Result codes    noErr       No error
  12472.                 bdNamErr    Bad file name
  12473.                 extFSErr    External file system
  12474.                 fnfErr      File not found
  12475.                 ioErr       I/O error
  12476.                 nsvErr      No such volume
  12477.                 opWrErr     File already open for writing
  12478.                 tmfoErr     Too many files open
  12479. \ FSRead
  12480. 17
  12481. Function FSRead (refNum: INTEGER; VAR count: LONGINT; buffPtr: Ptr)
  12482.                 : OSErr;
  12483.  
  12484.     FSRead attempts to read the number of bytes specified by the count
  12485. parameter from the open file whose access path is specified by
  12486. refNum, and transfer them to the data buffer pointed to by buffPtr.
  12487. The read operation begins at the current mark, so you might want to
  12488. precede this with a call to SetFPos. If you try to read past the
  12489. logical end-of-file, FSRead moves the mark to the end-of-file and
  12490. returns eofErr as its function result. After the read is completed,
  12491. the number of bytes actually read is returned in the count parameter.
  12492.  
  12493. Result codes    noErr       No error
  12494.                 eofErr      End-of-file
  12495.                 extFSErr    External file system
  12496.                 fnOpnErr    File not open
  12497.                 ioErr       I/O error
  12498.                 paramErr    Negative count
  12499.                 rfNumErr    Bad reference number
  12500. \ FSWrite
  12501. 17
  12502. Function FSWrite (refNum: INTEGER; VAR count: LONGINT; buffPtr: Ptr)
  12503.                     : OSErr;
  12504.  
  12505.     FSWrite takes the number of bytes specified by the count parameter
  12506. from the buffer pointed to by buffPtr and attempts to write them to
  12507. the open file whose access path is specified by refNum. The write
  12508. operation begins at the current mark, so you might want to precede
  12509. this with a call to SetFPos. After the write is completed, the number
  12510. of bytes actually written is returned in the count parameter.
  12511.  
  12512. Result codes    noErr       No error
  12513.                 dskFulErr   Disk full
  12514.                 fLckdErr    File locked
  12515.                 fnOpnErr    File not open
  12516.                 ioErr       I/O error
  12517.                 paramErr    Negative count
  12518.                 rfNumErr    Bad reference number
  12519.                 vLckdErr    Software volume lock
  12520.                 wPrErr      Hardware volume lock
  12521.                 wrPermErr   Read/write permission doesn’t allow writing
  12522. \ GetFPos
  12523. 17
  12524. Function GetFPos (refNum: INTEGER; VAR filePos: LONGINT)
  12525.                 : OSErr;
  12526.  
  12527.     GetFPos returns, in filePos, the mark of the open file whose access
  12528. path is specified by refNum.
  12529.  
  12530. Result codes    noErr       No error
  12531.                 extFSErr    External file system
  12532.                 fnOpnErr    File not open
  12533.                 ioErr       I/O error
  12534.                 rfNumErr    Bad reference number
  12535. \ SetFPos
  12536. 17
  12537. Function SetFPos (refNum: INTEGER; posMode: INTEGER; posOff: LONGINT)
  12538.                     : OSErr;
  12539.  
  12540.     SetFPos sets the mark of the open file whose access path is
  12541. specified by refNum to the position specified by posMode and posOff
  12542. (except when posMode is equal to fsAtMark, in which case posOff is
  12543. ignored). PosMode indicates how to position the mark; it must contain
  12544. one of the following values:
  12545.  
  12546. CONST fsAtMark    = 0;  {at current mark}
  12547.       fsFromStart = 1;  {set mark relative to beginning of file}
  12548.       fsFromLEOF  = 2;  {set mark relative to logical end-of-file}
  12549.       fsFromMark  = 3;  {set mark relative to current mark}
  12550.  
  12551.     If you specify fsAtMark, posOffset is ignored and the mark is left
  12552. wherever it’s currently positioned. If you choose to set the mark
  12553. (relative to either the beginning of the file, the logical end-of-file,
  12554. or the current mark), posOffset specifies the byte offset from the
  12555. chosen point (either positive or negative) where the mark should be set.
  12556. If you try to set the mark past the logical end-of-file, SetFPos moves
  12557. the mark to the end-of-file and returns eofErr as its function result.
  12558.  
  12559. Result codes    noErr       No error
  12560.                 eofErr      End-of-file
  12561.                 extFSErr    External file system
  12562.                 fnOpnErr    File not open
  12563.                 ioErr       I/O error
  12564.                 posErr      Attempt to position before start of file
  12565.                 rfNumErr    Bad reference number
  12566.  
  12567. \ GEtEOF
  12568. 17
  12569. Function GetEOF (refNum: INTEGER; VAR logEOF: LONGINT)
  12570.                 : OSErr;
  12571.  
  12572.     GetEOF returns, in logEOF, the logical end-of-file of the open
  12573. file whose access path is specified by refNum.
  12574.  
  12575. Result codes    noErr       No error
  12576.                 extFSErr    External file system
  12577.                 fnOpnErr    File not open
  12578.                 ioErr       I/O error
  12579.                 rfNumErr    Bad reference number
  12580. \ SetEOF
  12581. 17
  12582. Function SetEOF (refNum: INTEGER; logEOF: LONGINT)
  12583.                 : OSErr;
  12584.  
  12585.     SetEOF sets the logical end-of-file of the open file whose access
  12586. path is specified by refNum to the position specified by logEOF.
  12587. If you attempt to set the logical end-of-file beyond the physical
  12588. end-of-file, the physical end-of-file is set to one byte beyond
  12589. the end of the next free allocation block; if there isn’t enough
  12590. space on the volume, no change is made, and SetEOF returns dskFulErr
  12591. as its function result. If logEOF is 0, all space occupied by the file
  12592. on the volume is released.
  12593.  
  12594. Result codes    noErr       No error
  12595.                 dskFulErr   Disk full
  12596.                 extFSErr    External file system
  12597.                 fLckdErr    File locked
  12598.                 fnOpnErr    File not open
  12599.                 ioErr       I/O error
  12600.                 rfNumErr    Bad reference number
  12601.                 vLckdErr    Software volume lock
  12602.                 wPrErr      Hardware volume lock
  12603.                 wrPermErr   Read/write permission doesn’t allow writing
  12604. \ Allocate
  12605. 17
  12606. Function Allocate (refNum: INTEGER; VAR count: LONGINT)
  12607.                     : OSErr;
  12608.  
  12609.     Allocate adds the number of bytes specified by the count parameter
  12610. to the open file whose access path is specified by refNum, and sets the
  12611. physical end-of-file to one byte beyond the last block allocated.
  12612. The number of bytes actually allocated is rounded up to the nearest
  12613. multiple of the allocation block size, and returned in the count
  12614. parameter. If there isn’t enough empty space on the volume to satisfy
  12615. the allocation request, Allocate allocates the rest of the space on the
  12616. volume and returns dskFulErr as its function result.
  12617.  
  12618. Result codes    noErr       No error
  12619.                 dskFulErr   Disk full
  12620.                 fLckdErr    File locked
  12621.                 fnOpnErr    File not open
  12622.                 ioErr       I/O error
  12623.                 rfNumErr    Bad reference number
  12624.                 vLckdErr    Software volume lock
  12625.                 wPrErr      Hardware volume lock
  12626.                 wrPermErr   Read/write permission doesn’t allow writing
  12627. \ FSClose
  12628. 17
  12629. Function FSClose (refNum: INTEGER) : OSErr;
  12630.  
  12631.     FSClose removes the access path specified by refNum, writes the
  12632. contents of the volume buffer to the volume, and updates the file’s
  12633. entry in the file directory.
  12634.  
  12635. Note:  There’s no guarantee that any bytes have been written until
  12636.        FlushVol is called.
  12637.  
  12638. Result codes    noErr       No error
  12639.                 extFSErr    External file system
  12640.                 fnfErr      File not found
  12641.                 fnOpnErr    File not open
  12642.                 ioErr       I/O error
  12643.                 nsvErr      No such volume
  12644.                 rfNumErr    Bad reference number
  12645. \ GetFInfo
  12646. 17
  12647. Function GetFInfo (fileName: Str255; vRefNum: INTEGER; VAR
  12648.                     fndrInfo: FInfo) : OSErr;
  12649.  
  12650.     For the file having the name fileName on the specified volume,
  12651. GetFInfo returns information used by the Finder in fndrInfo
  12652. (see the section “File Information Used by the Finder”).
  12653.  
  12654. Result codes    noErr       No error
  12655.                 bdNamErr    Bad file name
  12656.                 extFSErr    External file system
  12657.                 fnfErr      File not found
  12658.                 ioErr       I/O error
  12659.                 nsvErr      No such volume
  12660.                 paramErr    No default volume
  12661. \ SetFInfo
  12662. 17
  12663. Function SetFInfo (fileName: Str255; vRefNum: INTEGER;
  12664.                     fndrInfo: FInfo) : OSErr;
  12665.  
  12666.     For the file having the name fileName on the specified volume,
  12667. SetFInfo sets information used by the Finder to fndrInfo (see
  12668. the section “File Information Used by the Finder”).
  12669.  
  12670. Result codes    noErr       No error
  12671.                 extFSErr    External file system
  12672.                 fLckdErr    File locked
  12673.                 fnfErr      File not found
  12674.                 ioErr       I/O error
  12675.                 nsvErr      No such volume
  12676.                 vLckdErr    Software volume lock
  12677.                 wPrErr      Hardware volume lock
  12678. \ SetFLock
  12679. 17
  12680. Function SetFLock (fileName: Str255; vRefNum: INTEGER)
  12681.                 : OSErr;
  12682.  
  12683.     SetFLock locks the file having the name fileName on the specified
  12684. volume. Access paths currently in use aren’t affected.
  12685.  
  12686. Result codes    noErr       No error
  12687.                 extFSErr    External file system
  12688.                 fnfErr      File not found
  12689.                 ioErr       I/O error
  12690.                 nsvErr      No such volume
  12691.                 vLckdErr    Software volume lock
  12692.                 wPrErr      Hardware volume lock
  12693. \ RstFLock
  12694. 17
  12695. Function RstFLock (fileName: Str255; vRefNum: INTEGER)
  12696.                     : OSErr;
  12697.  
  12698.     RstFLock unlocks the file having the name fileName on the specified
  12699. volume. Access paths currently in use aren’t affected.
  12700.  
  12701. Result codes    noErr       No error
  12702.                 extFSErr    External file system
  12703.                 fnfErr      File not found
  12704.                 ioErr       I/O error
  12705.                 nsvErr      No such volume
  12706.                 vLckdErr    Software volume lock
  12707.                 wPrErr      Hardware volume lock
  12708. \ Rename
  12709. 17
  12710. Function Rename (oldName: Str255; vRefNum: INTEGER; newName: Str255)
  12711.                 : OSErr;
  12712.  
  12713.     Given a file name in oldName, Rename changes the name of the file to
  12714. newName. Access paths currently in use aren’t affected. Given a volume
  12715. name in oldName or a volume reference number in vRefNum, Rename changes
  12716. the name of the specified volume to newName.
  12717.  
  12718. Warning:  If you’re renaming a volume, be sure that both names end with
  12719.           a colon.
  12720.  
  12721. Result codes    noErr       No error
  12722.                 bdNamErr    Bad file name
  12723.                 dirFulErr   Directory full
  12724.                 dupFNErr    Duplicate file name
  12725.                 extFSErr    External file system
  12726.                 fLckdErr    File locked
  12727.                 fnfErr      File not found
  12728.                 fsRnErr     Problem during rename
  12729.                 ioErr       I/O error
  12730.                 nsvErr      No such volume
  12731.                 paramErr    No default volume
  12732.                 vLckdErr    Software volume lock
  12733.                 wPrErr      Hardware volume lock
  12734. \ FSDelete
  12735. 17
  12736. Function FSDelete (fileName: Str255; vRefNum: INTEGER)
  12737.                     : OSErr;
  12738.  
  12739.     FSDelete removes the closed file having the name fileName from the
  12740. specified volume.
  12741.  
  12742. Note:  This function will delete both forks of a file.
  12743.  
  12744. Result codes    noErr       No error
  12745.                 bdNamErr    Bad file name
  12746.                 extFSErr    External file system
  12747.                 fBsyErr     File busy
  12748.                 fLckdErr    File locked
  12749.                 fnfErr      File not found
  12750.                 ioErr       I/O error
  12751.                 nsvErr      No such volume
  12752.                 vLckdErr    Software volume lock
  12753.                 wPrErr      Hardware volume lock
  12754. \ OpenRF
  12755. 17
  12756. Function OpenRF (fileName: Str255; vRefNum: INTEGER;
  12757.                 VAR refNum: INTEGER) : OSErr;
  12758.  
  12759.     OpenRF is similar to FSOpen; the only difference is that OpenRF
  12760. opens the resource fork of the specified file rather than the data fork.
  12761. A path reference number is returned in refNum. The access path’s
  12762. read/write permission is set to whatever the file’s open permission
  12763. allows.
  12764.  
  12765. Note:  Normally you should access a file’s resource fork through the
  12766.        routines of the Resource Manager rather than the File Manager.
  12767.        OpenRF doesn’t read the resource map into memory; it’s really
  12768.        only useful for block-level operations such as copying files.
  12769.  
  12770. Result codes    noErr       No error
  12771.                 bdNamErr    Bad file name
  12772.                 extFSErr    External file system
  12773.                 fnfErr      File not found
  12774.                 ioErr       I/O error
  12775.                 nsvErr      No such volume
  12776.                 opWrErr     File already open for writing
  12777.                 tmfoErr     Too many files open
  12778. \ FInitQueue
  12779. 17
  12780. Procedure InitQueue;
  12781.  
  12782. Trap macro  _InitQueue
  12783.  
  12784. FInitQueue clears all queued File Manager calls except the current one.
  12785. \ PBMountVol
  12786. 17
  12787. Function PBMountVol (paramBlock: ParmBlkPtr) : OSErr;
  12788.  
  12789. Trap macro  _MountVol
  12790.  
  12791. Parameter block
  12792.     <—  16  ioResult    word
  12793.     <–> 22  ioVRefNum   word
  12794.  
  12795.     PBMountVol mounts the volume in the drive specified by ioVRefNum,
  12796. and returns a volume reference number in ioVRefNum. If there are no
  12797. volumes already mounted, this volume becomes the default volume.
  12798. PBMountVol is always executed synchronously.
  12799.  
  12800. Note:  When mounting hierarchical volumes, PBMountVol opens two files
  12801.        needed for maintaining file directory and file mapping
  12802.        information. PBMountVol can fail if there are no access paths
  12803.        available for these two files; it will return tmfoErr as its
  12804.        function result.
  12805.  
  12806. Result codes    noErr       No error
  12807.                 badMDBErr   Bad master directory block
  12808.                 extFSErr    External file system
  12809.                 ioErr       I/O error
  12810.                 memFullErr  Not enough room in heap zone
  12811.                 noMacDskErr Not a Macintosh disk
  12812.                 nsDrvErr    No such drive
  12813.                 paramErr    Bad drive number
  12814.                 tmfoErr     Too many files open
  12815.                 volOnLinErr Volume already on-line
  12816. \ PBGetVInfo
  12817. 17
  12818. Function PBGetVInfo (paramBlock: ParmBlkPtr; async: BOOLEAN) : OSErr;
  12819.  
  12820. Trap macro  _GetVolInfo
  12821.  
  12822. Parameter block
  12823.     —>  12      ioCompletion    pointer
  12824.     <—  16      ioResult        word
  12825.     <–> 18      ioNamePtr       pointer
  12826.     <–> 22      ioVRefNum       word
  12827.     —>  28      ioVolIndex      word
  12828.     <—  30      ioVCrDate       long word
  12829.     <—  34      ioVLsBkUp       long word
  12830.     <—  38      ioVAtrb         word
  12831.     <—  40      ioVNmFls        word
  12832.     <—  42      ioVDirSt        word
  12833.     <—  44      ioVBlLn         word
  12834.     <—  46      ioVNmAlBlks     word
  12835.     <—  48      ioVAlBlkSiz     long word
  12836.     <—  52      ioVClpSiz       long word
  12837.     <—  56      ioAlBlSt        word
  12838.     <—  58      ioVNxtFNum      long word
  12839.     <—  62      ioVFrBlk        word
  12840.  
  12841.     PBGetVInfo returns information about the specified volume. If
  12842. ioVolIndex is positive, the File Manager attempts to use it to find the
  12843. volume; for instance, if ioVolIndex is 2, the File Manager will attempt
  12844. to access the second mounted volume. If ioVolIndex is negative, the
  12845. File Manager uses ioNamePtr and ioVRefNum in the standard way (described
  12846. in the section “Specifying Volumes, Directories, and Files”) to
  12847. determine which volume. If ioVolIndex is 0, the File Manager attempts
  12848. to access the volume by using ioVRefNum only. The volume reference
  12849. number is returned in ioVRefNum, and a pointer to the volume name is
  12850. returned in ioNamePtr (unless ioNamePtr is NIL).
  12851.  
  12852.     If a working directory reference number is passed in ioVRefNum (or
  12853. if the default directory is a subdirectory), the number of files and
  12854. directories in the specified directory (the directory’s valence) will be
  12855. returned in ioVNmFls. Also, the volume reference number won’t be
  12856. returned; ioVRefNum will still contain the working directory reference
  12857. number.
  12858.  
  12859. Warning:  IOVNmAlBlks and ioVFrBlks, which are actually unsigned
  12860.           integers, are clipped to 31744 ($7C00) regardless of the size
  12861.           of the volume.
  12862.  
  12863. Result codes    noErr       No error
  12864.                 nsvErr      No such volume
  12865.                 paramErr    No default volume
  12866. \ PBHGetVInfo
  12867. 17
  12868. Function PBHGetVInfo (paramBlock: HParmBlkPtr; async: BOOLEAN) : OSErr;
  12869.  
  12870. Trap macro  _HGetVInfo
  12871.  
  12872. Parameter block
  12873.     —>  12  ioCompletion    pointer
  12874.     <—  16  ioResult        word
  12875.     <–> 18  ioNamePtr       pointer
  12876.     <–> 22  ioVRefNum       word
  12877.     —>  28  ioVolIndex      word
  12878.     <—  30  ioVCrDate       long word
  12879.     <—  34  ioVLsMod        long word
  12880.     <—  38  ioVAtrb         word
  12881.     <—  40  ioVNmFls        word
  12882.     <—  42  ioVBitMap       word
  12883.     <—  44  ioVAllocPtr     word
  12884.     <—  46  ioVNmAlBlks     word
  12885.     <—  48  ioVAlBlkSiz     long word
  12886.     <—  52  ioVClpSiz       long word
  12887.     <—  56  ioAlBlSt        word
  12888.     <—  58  ioVNxtFNum      long word
  12889.     <—  62  ioVFrBlk        word
  12890.     <—  64  ioVSigWord      word
  12891.     <—  66  ioVDrvInfo      word
  12892.     <—  68  ioVDRefNum      word
  12893.     <—  70  ioVFSID         word
  12894.     <—  72  ioVBkUp         long word
  12895.     <—  76  ioVSeqNum       word
  12896.     <—  78  ioVWrCnt        long word
  12897.     <—  82  ioVFilCnt       long word
  12898.     <—  86  ioVDirCnt       long word
  12899.     <—  90  ioVFndrInfo     32 bytes
  12900.  
  12901.     PBHGetVInfo is similar in function to PBGetVInfo but returns a
  12902. larger parameter block. In addition, PBHGetVInfo always returns the
  12903. volume reference number in ioVRefNum (regardless of what was passed in).
  12904. Also, ioVNmAlBlks and ioVFrBlks are not clipped as they are by
  12905. PBGetVInfo.
  12906.  
  12907. Result codes    noErr       No error
  12908.                 nsvErr      No such volume
  12909.                 paramErr    No default volume
  12910. \ PBSetVInfo
  12911. 17
  12912. Function PBSetVInfo (paramBlock: HParmBlkPtr; async: BOOLEAN) : OSErr;
  12913.  
  12914. Trap macro  _SetVolInfo
  12915.  
  12916. Parameter block
  12917.     —>  12  ioCompletion    pointer
  12918.     <—  16  ioResult        word
  12919.     —>  18  ioNamePtr       pointer
  12920.     —>  22  ioVRefNum       word
  12921.     —>  30  ioVCrDate       long word
  12922.     —>  34  ioVLsMod        long word
  12923.     —>  38  ioVAtrb         word
  12924.     —>  52  ioVClpSiz       long word
  12925.     —>  72  ioVBkUp         long word
  12926.     —>  76  ioVSeqNum       word
  12927.     —>  90  ioVFndrInfo     32 bytes
  12928.  
  12929.     PBSetVInfo lets you modify information about volumes. A pointer to
  12930. a new name for the volume can be specified in ioNamePtr. The date and
  12931. time of the volume’s creation and modification can be set with ioVCrDate
  12932. and ioVLsMod respectively. Only bit 15 of ioVAtrb can be changed;
  12933. setting it locks the volume.
  12934.  
  12935. Note: The volume cannot be specified by name; you must use either the
  12936.        volume reference number or the drive number.
  12937.  
  12938. Warning:  PBSetVInfo operates only with the hierarchical version of the
  12939.           File Manager; if used on a Macintosh equipped only with the
  12940.           64K ROM version of the File Manager, it will generate a system
  12941.           error.
  12942.  
  12943. Result codes    noErr       No error
  12944.                 nsvErr      No such volume
  12945.                 paramErr    No default volume
  12946. \ PBGetVol
  12947. 17
  12948. Function PBGetVol (paramBlock: ParmBlkPtr; async: BOOLEAN) : OSErr;
  12949.  
  12950. Trap macro  _GetVol
  12951.  
  12952. Parameter block
  12953.     —>  12  ioCompletion    pointer
  12954.     <—  16  ioResult        word
  12955.     <—  18  ioNamePtr       pointer
  12956.     <—  22  ioVRefNum       word
  12957.  
  12958.     PBGetVol returns a pointer to the name of the default volume in
  12959. ioNamePtr (unless ioNamePtr is NIL) and its volume reference number in
  12960. ioVRefNum. If a default directory was set with a previous PBSetVol
  12961. call, a pointer to its name will be returned in ioNamePtr and its
  12962. working directory reference number in ioVRefNum.
  12963.  
  12964. Result codes    noErr   No error
  12965.                 nsvErr  No default volume
  12966. \ PBHGetVol
  12967. 17
  12968. Function PBHGetVol (paramBlock: WDPBPtr; async: BOOLEAN) : OSErr;
  12969.  
  12970. Trap macro  _HGetVol
  12971.  
  12972. Parameter block
  12973.     —>  12  ioCompletion    pointer
  12974.     <—  16  ioResult        word
  12975.     <—  18  ioNamePtr       pointer
  12976.     <—  22  ioVRefNum       word
  12977.     <—  28  ioWDProcID      long word
  12978.     <—  32  ioWDVRefNum     word
  12979.     <—  48  ioWDDirID       long word
  12980.  
  12981.     PBHGetVol returns the default volume and directory last set by
  12982. either a PBSetVol or a PBHSetVol call. The reference number of the
  12983. default volume is returned in ioVRefNum.
  12984.  
  12985. Warning:  IOVRefNum will return a working directory reference number
  12986.           (instead of the volume reference number) if, in the last call
  12987.           to PBSetVol or PBHSetVol, a working directory reference number
  12988.           was passed in this field.
  12989.  
  12990.     The volume reference number of the volume on which the default
  12991. directory exists is returned in ioWDVRefNum. The directory ID of the
  12992. default directory is returned in ioWDDirID.
  12993.  
  12994. Result codes    noErr   No error
  12995.                 nsvErr  No default volume
  12996. \ PBSetVol
  12997. 17
  12998. Function PBSetVol (paramBlock: ParmBlkPtr; async: BOOLEAN) : OSErr;
  12999.  
  13000. Trap macro  _SetVol
  13001.  
  13002. Parameter block
  13003.     —>  12  ioCompletion    pointer
  13004.     <—  16  ioResult        word
  13005.     —>  18  ioNamePtr       pointer
  13006.     —>  22  ioVRefNum       word
  13007.  
  13008.     PBSetVol sets the default volume to the mounted volume specified by
  13009. ioNamePtr or ioVRefNum. On hierarchical volumes, PBSetVol also sets the
  13010. root directory as the default directory.
  13011.  
  13012. Result codes    noErr       No error
  13013.                 bdNamErr    Bad volume name
  13014.                 nsvErr      No such volume
  13015.                 paramErr    No default volume
  13016. \ PBHSetVol
  13017. 17
  13018. Function PBHSetVol (paramBlock: WDPBPtr; async: BOOLEAN) : OSErr;
  13019.  
  13020. Trap macro  _HSetVol
  13021.  
  13022. Parameter block
  13023.     —>  12  ioCompletion    pointer
  13024.     <—  16  ioResult        word
  13025.     —>  18  ioNamePtr       pointer
  13026.     —>  22  ioVRefNum       word
  13027.     —>  48  ioWDDirID       long word
  13028.  
  13029.     PBHSetVol sets both the default volume and the default directory.
  13030. The default directory to be used can be specified by either a volume
  13031. reference number or a working directory reference number in ioVRefNum, a
  13032. directory ID in ioWDDirID, or a pointer to a pathname (possibly NIL) in
  13033. ioNamePtr.
  13034.  
  13035. Note:  Both the default volume and  the default directory are used in
  13036.        calls made with no volume name and a volume reference number of
  13037.        zero.
  13038.  
  13039. Result codes    noErr   No error
  13040.                 nsvErr  No default volume
  13041. \ PBFlushVol
  13042. 17
  13043. Function PBFlushVol (paramBlock: ParmBlkPtr; async: BOOLEAN) : OSErr;
  13044.  
  13045. Trap macro  _FlushVol
  13046.  
  13047. Parameter block
  13048.     —>  12  ioCompletion    pointer
  13049.     <—  16  ioResult        word
  13050.     —>  18  ioNamePtr       pointer
  13051.     —>  22  ioVRefNum       word
  13052.  
  13053.     On the volume specified by ioNamePtr or ioVRefNum, PBFlushVol writes
  13054. descriptive information about the volume, the contents of the associated
  13055. volume buffer, and all access path buffers for the volume (if they’ve
  13056. changed since the last time PBFlushVol was called).
  13057.  
  13058. Note:  The date and time of the last modification to the volume are set
  13059.        when the modification is made, not when the volume is flushed.
  13060.  
  13061. Result codes    noErr       No error
  13062.                 bdNamErr    Bad volume name
  13063.                 extFSErr    External file system
  13064.                 ioErr       I/O error
  13065.                 nsDrvErr    No such drive
  13066.                 nsvErr      No such volume
  13067.                 paramErr    No default volume
  13068. \ PBUnmountVol
  13069. 17
  13070. Function PBUnmountVol (paramBlock: ParmBlkPtr) : OSErr;
  13071.  
  13072. Trap macro  _UnmountVol
  13073.  
  13074. Parameter block
  13075.     <—  16  ioResult    word
  13076.     —>  18  ioNamePtr   pointer
  13077.     —>  22  ioVRefNum   word
  13078.  
  13079.     PBUnmountVol unmounts the volume specified by ioNamePtr or
  13080. ioVRefNum, by calling PBFlushVol to flush the volume, closing all open
  13081. files on the volume, and releasing the memory used for the volume.
  13082. PBUnmountVol is always executed synchronously.
  13083.  
  13084. Warning:  Don’t unmount the startup volume.
  13085.  
  13086. Note:  Unmounting a volume does not close working directories; to
  13087.        release the memory allocated to a working directory, call
  13088.        PBCloseWD.
  13089.  
  13090. Result codes    noErr       No error
  13091.                 bdNamErr    Bad volume name
  13092.                 extFSErr    External file system
  13093.                 ioErr       I/O error
  13094.                 nsDrvErr    No such drive
  13095.                 nsvErr      No such volume
  13096.                 paramErr    No default volume
  13097. \ PBOffLine
  13098. 17
  13099. Function PBOffLine (paramBlock: ParmBlkPtr) : OSErr;
  13100.  
  13101. Trap macro  _OffLine
  13102.  
  13103. Parameter block
  13104.     —>  12  ioCompletion    pointer
  13105.     <—  16  ioResult    word
  13106.     —>  18  ioNamePtr   pointer
  13107.     —>  22  ioVRefNum   word
  13108.  
  13109.     PBOffLine places off-line the volume specified by ioNamePtr or
  13110. ioVRefNum, by calling PBFlushVol to flush the volume and releasing all
  13111. the memory used for the volume except for the volume control block.
  13112. PBOffLine is always executed synchronously.
  13113.  
  13114. Result codes    noErr       No error
  13115.                 bdNamErr    Bad volume name
  13116.                 extFSErr    External file system
  13117.                 ioErr       I/O error
  13118.                 nsDrvErr    No such drive
  13119.                 nsvErr      No such volume
  13120.                 paramErr    No default volume
  13121. \ PBEject
  13122. 17
  13123. Function PBEject (paramBlock: ParmBlkPtr) : OSErr;
  13124.  
  13125. Trap macro  _Eject
  13126.  
  13127. Parameter block
  13128.     —>  12  ioCompletion    pointer
  13129.     <—  16  ioResult        word
  13130.     —>  18  ioNamePtr       pointer
  13131.     —>  22  ioVRefNum       word
  13132.  
  13133.     PBEject flushes the volume specified by ioNamePtr or ioVRefNum,
  13134. places it off-line, and then ejects the volume.
  13135. ________________________________________________________________________
  13136.  
  13137. Assembly-language note:  You may invoke the macro _Eject asynchronously;
  13138. the first part of the call is executed synchronously, and the actual
  13139. ejection is executed asynchronously.
  13140. ________________________________________________________________________
  13141. Result codes    noErr       No error
  13142.                 bdNamErr    Bad volume name
  13143.                 extFSErr    External file system
  13144.                 ioErr       I/O error
  13145.                 nsDrvErr    No such drive
  13146.                 nsvErr      No such volume
  13147.                 paramErr    No default volume
  13148. \ PBOpen
  13149. 17
  13150. Function PBOpen (paramBlock: ParmBlkPtr; async: BOOLEAN) : OSErr;
  13151.  
  13152. Trap macro  _Open
  13153.  
  13154. Parameter block
  13155.     —>  12  ioCompletion    pointer
  13156.     <—  16  ioResult        word
  13157.     —>  18  ioNamePtr       pointer
  13158.     —>  22  ioVRefNum       word
  13159.     <—  24  ioRefNum        word
  13160.     —>  26  ioVersNum       byte
  13161.     —>  27  ioPermssn       byte
  13162.     —>  28  ioMisc          pointer
  13163.  
  13164.     PBOpen creates an access path to the file having the name pointed to
  13165. by ioNamePtr (and on flat volumes, the version number ioVersNum) on the
  13166. volume specified by ioVRefNum. A path reference number is returned in
  13167. ioRefNum.
  13168.  
  13169.     IOMisc either points to a portion of memory (522 bytes) to be used
  13170. as the access path’s buffer, or is NIL if you want the volume buffer to
  13171. be used instead.
  13172.  
  13173. Warning:  All access paths to a single file that’s opened multiple times
  13174.           should share the same buffer so that they will read and write
  13175.           the same data.
  13176.  
  13177.     IOPermssn specifies the path’s read/write permission. A path can be
  13178. opened for writing even if it accesses a file on a locked volume, and an
  13179. error won’t be returned until a PBWrite, PBSetEOF, or PBAllocate call is
  13180. made.
  13181.  
  13182.     If you attempt to open a locked file for writing, PBOpen will return
  13183. permErr as its function result. If you request exclusive read/write
  13184. permission but another access path already has write permission (whether
  13185. write only, exclusive read/write, or shared read/write), PBOpen will
  13186. return the reference number of the existing access path in ioRefNum and
  13187. opWrErr as its function result. Similarly, if you request shared
  13188. read/write permission but another access path already has exclusive
  13189. read/write permission, PBOpen will return the reference number of the
  13190. access path in ioRefNum and opWrErr as its function result.
  13191.  
  13192. Result codes    noErr       No error
  13193.                 bdNamErr    Bad file name
  13194.                 extFSErr    External file system
  13195.                 fnfErr      File not found
  13196.                 ioErr       I/O error
  13197.                 nsvErr      No such volume
  13198.                 opWrErr     File already open for writing
  13199.                 permErr     Attempt to open locked file for writing
  13200.                 tmfoErr     Too many files open
  13201. \ PBHOpen
  13202. 17
  13203. Function PBHOpen (paramBlock: HParmBlkPtr; async: BOOLEAN) : OSErr;
  13204.  
  13205. Trap macro  _HOpen
  13206.  
  13207. Parameter block
  13208.     —>  12  ioCompletion    pointer
  13209.     <—  16  ioResult        word
  13210.     —>  18  ioNamePtr       pointer
  13211.     —>  22  ioVRefNum       word
  13212.     <—  24  ioRefNum        word
  13213.     —>  27  ioPermssn       byte
  13214.     —>  28  ioMisc          pointer
  13215.     —>  48  ioDirID         long word
  13216.  
  13217.     PBHOpen is identical to PBOpen except that it accepts a directory ID
  13218. in ioDirID.
  13219.  
  13220. Result codes    noErr       No error
  13221.                 bdNamErr    Bad file name
  13222.                 dirNFErr    Directory not found or incomplete pathname
  13223.                 extFSErr    External file system
  13224.                 fnfErr      File not found
  13225.                 ioErr       I/O error
  13226.                 nsvErr      No such volume
  13227.                 opWrErr     File already open for writing
  13228.                 permErr     Attempt to open locked file for writing
  13229.                 tmfoErr     Too many files open
  13230.  
  13231. \ PBOpenRF
  13232. 17
  13233. Function PBOpenRF (paramBlock: ParmBlkPtr; async: BOOLEAN) : OSErr;
  13234.  
  13235. Trap macro  _OpenRF
  13236.  
  13237. Parameter block
  13238.     —>  12  ioCompletion    pointer
  13239.     <—  16  ioResult        word
  13240.     —>  18  ioNamePtr       pointer
  13241.     —>  22  ioVRefNum       word
  13242.     <—  24  ioRefNum        word
  13243.     —>  26  ioVersNum       byte
  13244.     —>  27  ioPermssn       byte
  13245.     —>  28  ioMisc          pointer
  13246.  
  13247.     PBOpenRF is identical to PBOpen, except that it opens the file’s
  13248. resource fork instead of its data fork.
  13249.  
  13250. Note:  Normally you should access a file’s resource fork through the
  13251.        routines of the Resource Manager rather than the File Manager.
  13252.        PBOpenRF doesn’t read the resource map into memory; it’s really
  13253.        only useful for block-level operations such as copying files.
  13254.  
  13255. Result codes    noErr       No error
  13256.                 bdNamErr    Bad file name
  13257.                 extFSErr    External file system
  13258.                 fnfErr      File not found
  13259.                 ioErr       I/O error
  13260.                 nsvErr      No such volume
  13261.                 opWrErr     File already open for writing
  13262.                 permErr     Attempt to open locked file for writing
  13263.                 tmfoErr     Too many files open
  13264. \ PBHOpenRF
  13265. 17
  13266. Function PBHOpenRF (paramBlock: HParmBlkPtr; async: BOOLEAN) : OSErr;
  13267.  
  13268. Trap macro  _HOpenRF
  13269.  
  13270. Parameter block
  13271.     —>  12  ioCompletion    pointer
  13272.     <—  16  ioResult        word
  13273.     —>  18  ioNamePtr       pointer
  13274.     —>  22  ioVRefNum       word
  13275.     <—  24  ioRefNum        word
  13276.     —>  27  ioPermssn       byte
  13277.     —>  28  ioMisc          pointer
  13278.     —>  48  ioDirID         long word
  13279.  
  13280.     PBHOpenRF is identical to PBOpenRF except that it accepts a
  13281. directory ID in ioDirID.
  13282.  
  13283. Result codes    noErr       No error
  13284.                 bdNamErr    Bad file name
  13285.                 dirNFErr    Directory not found or incomplete pathname
  13286.                 extFSErr    External file system
  13287.                 fnfErr      File not found
  13288.                 ioErr       I/O error
  13289.                 nsvErr      No such volume
  13290.                 opWrErr     File already open for writing
  13291.                 permErr     Attempt to open locked file for writing
  13292.                 tmfoErr     Too many files open
  13293. \ PBLockRange
  13294. 17
  13295. Function PBLockRange (paramBlock: ParmBlkPtr; async: BOOLEAN) : OSErr;
  13296.  
  13297. Trap macro  _LockRng
  13298.  
  13299. Parameter block
  13300.     —>  12  ioCompletion    pointer
  13301.     <—  16  ioResult        word
  13302.     —>  24  ioRefNum        word
  13303.     —>  36  ioReqCount      long word
  13304.     —>  44  ioPosMode       word
  13305.     —>  46  ioPosOffset     long word
  13306.  
  13307.     On a file opened with a shared read/write permission, PBLockRange is
  13308. used in conjunction with PBRead and PBWrite to lock a certain portion of
  13309. the file. PBLockRange uses the same parameters as both PBRead and
  13310. PBWrite; by calling it immediately before PBRead, you can use the
  13311. information present in the parameter block for the PBRead call.
  13312.  
  13313.     When you’re finished with the data (typically after a call to
  13314. PBWrite), be sure to call PBUnlockRange to free up that portion of the
  13315. file for subsequent PBRead calls.
  13316.  
  13317. Warning:  PBLockRange operates only with the hierarchical version of the
  13318.           File Manager; if used on a Macintosh equipped only with the
  13319.           64K ROM version of the File Manager, it will generate a system
  13320.           error.
  13321.  
  13322. Result codes    noErr       No error
  13323.                 eofErr      End-of-file
  13324.                 extFSErr    External file system
  13325.                 fnOpnErr    File not open
  13326.                 ioErr       I/O error
  13327.                 paramErr    Negative ioReqCount
  13328.                 rfNumErr    Bad reference number
  13329. \ PBUnlockRange
  13330. 17
  13331. Function PBUnlockRange (paramBlock: ParmBlkPtr; async: BOOLEAN) : OSErr;
  13332.  
  13333. Trap macro  _UnlockRng
  13334.  
  13335. Parameter block
  13336.     —>  12  ioCompletion    pointer
  13337.     <—  16  ioResult        word
  13338.     —>  24  ioRefNum        word
  13339.     —>  36  ioReqCount      long word
  13340.     —>  44  ioPosMode       word
  13341.     —>  46  ioPosOffset     long word
  13342.  
  13343.     PBUnlockRange is used in conjunction with PBRead and PBWrite to
  13344. unlock a certain portion of a file that you locked with PBLockRange.
  13345. PBUnlockRange uses the same parameters as both PBRead and PBWrite; by
  13346. calling it immediately after PBWrite, you can use the information
  13347. present in the parameter block to unlock the portion of the file that
  13348. was just written.
  13349.  
  13350. Warning:  PBUnlockRange operates only with the hierarchical version of
  13351.           the File Manager; if used on a Macintosh equipped only with
  13352.           the 64K ROM version of the File Manager, it will generate a
  13353.           system error.
  13354.  
  13355. Result codes    noErr       No error
  13356.                 eofErr      End-of-file
  13357.                 extFSErr    External file system
  13358.                 fnOpnErr    File not open
  13359.                 ioErr       I/O error
  13360.                 paramErr    Negative ioReqCount
  13361.                 rfNumErr    Bad reference number
  13362. \ PBRead
  13363. 17
  13364. Function PBRead (paramBlock: ParmBlkPtr; async: BOOLEAN) : OSErr;
  13365.  
  13366. Trap macro  _Read
  13367.  
  13368. Parameter block
  13369.     —>  12  ioCompletion    pointer
  13370.     <—  16  ioResult        word
  13371.     —>  24  ioRefNum        word
  13372.     —>  32  ioBuffer        pointer
  13373.     —>  36  ioReqCount      long word
  13374.     <—  40  ioActCount      long word
  13375.     —>  44  ioPosMode       word
  13376.     <–> 46  ioPosOffset     long word
  13377.  
  13378.     PBRead attempts to read ioReqCount bytes from the open file whose
  13379. access path is specified by ioRefNum, and transfer them to the data
  13380. buffer pointed to by ioBuffer. The position of the mark is specified by
  13381. ioPosMode and ioPosOffset. If you try to read past the logical
  13382. end-of-file, PBRead moves the mark to the end-of-file and returns eofErr
  13383. as its function result. After the read is completed, the mark is
  13384. returned in ioPosOffset and the number of bytes actually read is
  13385. returned in ioActCount.
  13386.  
  13387. Result codes    noErr       No error
  13388.                 eofErr      End-of-file
  13389.                 extFSErr    External file system
  13390.                 fnOpnErr    File not open
  13391.                 ioErr       I/O error
  13392.                 paramErr    Negative ioReqCount
  13393.                 rfNumErr    Bad reference number
  13394. \ PBWrite
  13395. 17
  13396. Function PBWrite (paramBlock: ParmBlkPtr; async: BOOLEAN) : OSErr;
  13397.  
  13398. Trap macro  _Write
  13399.  
  13400. Parameter block
  13401.     —>  12  ioCompletion    pointer
  13402.     <—  16  ioResult        word
  13403.     —>  24  ioRefNum        word
  13404.     —>  32  ioBuffer        pointer
  13405.     —>  36  ioReqCount      long word
  13406.     <—  40  ioActCount      long word
  13407.     —>  44  ioPosMode       word
  13408.     <–> 46  ioPosOffset     long word
  13409.  
  13410.     PBWrite takes ioReqCount bytes from the buffer pointed to by
  13411. ioBuffer and attempts to write them to the open file whose access path
  13412. is specified by ioRefNum. The position of the mark is specified by
  13413. ioPosMode and ioPosOffset. After the write is completed, the mark is
  13414. returned in ioPosOffset and the number of bytes actually written is
  13415. returned in ioActCount.
  13416.  
  13417. Result codes    noErr       No error
  13418.                 dskFulErr   Disk full
  13419.                 fLckdErr    File locked
  13420.                 fnOpnErr    File not open
  13421.                 ioErr       I/O error
  13422.                 paramErr    Negative ioReqCount
  13423.                 posErr      Attempt to position before start of file
  13424.                 rfNumErr    Bad reference number
  13425.                 vLckdErr    Software volume lock
  13426.                 wPrErr      Hardware volume lock
  13427.                 wrPermErr   Read/write permission doesn’t allow writing
  13428. \ PBGetFPos
  13429. 17
  13430. Function PBGetFPos (paramBlock: ParmBlkPtr; async: BOOLEAN) : OSErr;
  13431.  
  13432. Trap macro  _GetFPos
  13433.  
  13434. Parameter block
  13435.     —>  12  ioCompletion    pointer
  13436.     <—  16  ioResult        word
  13437.     —>  24  ioRefNum        word
  13438.     <—  36  ioReqCount      long word
  13439.     <—  40  ioActCount      long word
  13440.     <—  44  ioPosMode       word
  13441.     <—  46  ioPosOffset     long word
  13442.  
  13443.     PBGetFPos returns, in ioPosOffset, the mark of the open file whose
  13444. access path is specified by ioRefNum. It sets ioReqCount, ioActCount,
  13445. and ioPosMode to 0.
  13446.  
  13447. Result codes    noErr       No error
  13448.                 extFSErr    External file system
  13449.                 fnOpnErr    File not open
  13450.                 gfpErr      Error during GetFPos
  13451.                 ioErr       I/O error
  13452.                 rfNumErr    Bad reference number
  13453. \ PBSetFPos
  13454. 17
  13455. Function PBSetFPos (paramBlock: ParmBlkPtr; async: BOOLEAN) : OSErr;
  13456.  
  13457. Trap macro  _SetFPos
  13458.  
  13459. Parameter block
  13460.     —>  12  ioCompletion    pointer
  13461.     <—  16  ioResult        word
  13462.     —>  24  ioRefNum        word
  13463.     —>  44  ioPosMode       word
  13464.     <–> 46  ioPosOffset     long word
  13465.  
  13466.     PBSetFPos sets the mark of the open file whose access path is
  13467. specified by ioRefNum to the position specified by ioPosMode and
  13468. ioPosOffset. The position at which the mark is actually set is returned
  13469. in ioPosOffset. If you try to set the mark past the logical
  13470. end-of-file, PBSetFPos moves the mark to the end-of-file and returns
  13471. eofErr as its function result.
  13472.  
  13473. Result codes    noErr       No error
  13474.                 eofErr      End-of-file
  13475.                 extFSErr    External file system
  13476.                 fnOpnErr    File not open
  13477.                 ioErr       I/O error
  13478.                 posErr      Attempt to position before start of file
  13479.                 rfNumErr    Bad reference number
  13480. \ PBGetEOF
  13481. 17
  13482. Function PBGetEOF (paramBlock: ParmBlkPtr; async: BOOLEAN) : OSErr;
  13483.  
  13484. Trap macro  _GetEOF
  13485.  
  13486. Parameter block
  13487.     —>  12  ioCompletion    pointer
  13488.     <—  16  ioResult        word
  13489.     —>  24  ioRefNum        word
  13490.     <—  28  ioMisc          long word
  13491.  
  13492.     PBGetEOF returns, in ioMisc, the logical end-of-file of the open
  13493. file whose access path is specified by ioRefNum.
  13494.  
  13495. Result codes    noErr       No error
  13496.                 extFSErr    External file system
  13497.                 fnOpnErr    File not open
  13498.                 ioErr       I/O error
  13499.                 rfNumErr    Bad reference number
  13500. \ PBSetEOF
  13501. 17
  13502. Function PBSetEOF (paramBlock: ParmBlkPtr; async: BOOLEAN) : OSErr;
  13503.  
  13504. Trap macro  _SetEOF
  13505.  
  13506. Parameter block
  13507.     —>  12  ioCompletion    pointer
  13508.     <—  16  ioResult        word
  13509.     —>  24  ioRefNum        word
  13510.     —>  28  ioMisc          long word
  13511.  
  13512.     PBSetEOF sets the logical end-of-file of the open file, whose access
  13513. path is specified by ioRefNum, to ioMisc. If you attempt to set the
  13514. logical end-of-file beyond the physical end-of-file, another allocation
  13515. block is added to the file; if there isn’t enough space on the volume,
  13516. no change is made, and PBSetEOF returns dskFulErr as its function
  13517. result. If ioMisc is 0, all space occupied by the file on the volume is
  13518. released.
  13519.  
  13520. Result codes    noErr       No error
  13521.                 dskFulErr   Disk full
  13522.                 extFSErr    External file system
  13523.                 fLckdErr    File locked
  13524.                 fnOpnErr    File not open
  13525.                 ioErr       I/O error
  13526.                 rfNumErr    Bad reference number
  13527.                 vLckdErr    Software volume lock
  13528.                 wPrErr      Hardware volume lock
  13529.                 wrPermErr   Read/write permission doesn’t allow writing
  13530. \ PBAllocate
  13531. 17
  13532. Function PBAllocate (paramBlock: ParmBlkPtr; async: BOOLEAN) : OSErr;
  13533.  
  13534. Trap macro  _Allocate
  13535.  
  13536. Parameter block
  13537.     —>  12  ioCompletion    pointer
  13538.     <—  16  ioResult        word
  13539.     —>  24  ioRefNum        word
  13540.     —>  36  ioReqCount      long word
  13541.     <—  40  ioActCount      long word
  13542.  
  13543.     PBAllocate adds ioReqCount bytes to the open file whose access path
  13544. is specified by ioRefNum, and sets the physical end-of-file to one byte
  13545. beyond the last block allocated. The number of bytes actually allocated
  13546. is rounded up to the nearest multiple of the allocation block size, and
  13547. returned in ioActCount. If there isn’t enough empty space on the volume
  13548. to satisfy the allocation request, PBAllocate allocates the rest of the
  13549. space on the volume and returns dskFulErr as its function result.
  13550.  
  13551. Note:  Even if the total number of requested bytes is unavailable,
  13552.        PBAllocate will allocate whatever space, contiguous or not, is
  13553.        available. To force the allocation of the entire requested space
  13554.        as a contiguous piece, call PBAllocContig instead.
  13555.  
  13556. Result codes    noErr       No error
  13557.                 dskFulErr   Disk full
  13558.                 fLckdErr    File locked
  13559.                 fnOpnErr    File not open
  13560.                 ioErr       I/O error
  13561.                 rfNumErr    Bad reference number
  13562.                 vLckdErr    Software volume lock
  13563.                 wPrErr      Hardware volume lock
  13564.                 wrPermErr   Read/write permission doesn’t allow writing
  13565. \ PBAllocContig
  13566. 17
  13567. Function PBAllocContig (paramBlock: ParmBlkPtr; async: BOOLEAN) : OSErr;
  13568.  
  13569. Trap macro  _AllocContig
  13570.  
  13571. Parameter block
  13572.     —>  12  ioCompletion    pointer
  13573.     <—  16  ioResult        word
  13574.     —>  24  ioRefNum        word
  13575.     —>  36  ioReqCount      long word
  13576.     <—  40  ioActCount      long word
  13577.  
  13578.     PBAllocContig is identical to PBAllocate except that if there isn’t
  13579. enough contiguous empty space on the volume to satisfy the allocation
  13580. request, PBAllocContig will do nothing and will return dskFulErr as its
  13581. Function result. If you want to allocate whatever space is available,
  13582. even when the entire request cannot be filled as a contiguous piece,
  13583. call PBAllocate instead.
  13584.  
  13585. Result codes    noErr       No error
  13586.                 dskFulErr   Disk full
  13587.                 fLckdErr    File locked
  13588.                 fnOpnErr    File not open
  13589.                 ioErr       I/O error
  13590.                 rfNumErr    Bad reference number
  13591.                 vLckdErr    Software volume lock
  13592.                 wPrErr      Hardware volume lock
  13593.                 wrPermErr   Read/write permission doesn’t allow writing
  13594. \ PBFlushFile
  13595. 17
  13596. Function PBFlushFile (paramBlock: ParmBlkPtr; async: BOOLEAN) : OSErr;
  13597.  
  13598. Trap macro  _FlushFile
  13599.  
  13600. Parameter block
  13601.     —>  12  ioCompletion    pointer
  13602.     <—  16  ioResult        word
  13603.     —>  24  ioRefNum        word
  13604.  
  13605.     PBFlushFile writes the contents of the access path buffer indicated
  13606. by ioRefNum to the volume, and updates the file’s entry in the file
  13607. directory (or in the file catalog, in the case of hierarchical volumes).
  13608.  
  13609. Warning:  Some information stored on the volume won’t be correct until
  13610.           PBFlushVol is called.
  13611.  
  13612. Result codes    noErr       No error
  13613.                 extFSErr    External file system
  13614.                 fnfErr      File not found
  13615.                 fnOpnErr    File not open
  13616.                 ioErr       I/O error
  13617.                 nsvErr      No such volume
  13618.                 rfNumErr    Bad reference number
  13619.  
  13620. \ PBClose
  13621. 17
  13622. Function PBClose (paramBlock: ParmBlkPtr; async: BOOLEAN) : OSErr;
  13623.  
  13624. Trap macro  _Close
  13625.  
  13626. Parameter block
  13627.     —>  12  ioCompletion    pointer
  13628.     <—  16  ioResult        word
  13629.     —>  24  ioRefNum        word
  13630.  
  13631.     PBClose writes the contents of the access path buffer specified by
  13632. ioRefNum to the volume and removes the access path.
  13633.  
  13634. Warning:  Some information stored on the volume won’t be correct until
  13635.           PBFlushVol is called.
  13636.  
  13637. Result codes    noErr       No error
  13638.                 extFSErr    External file system
  13639.                 fnfErr      File not found
  13640.                 fnOpnErr    File not open
  13641.                 ioErr       I/O error
  13642.                 nsvErr      No such volume
  13643.                 rfNumErr    Bad reference number
  13644.  
  13645. \ PBCreate
  13646. 17
  13647. Function PBCreate (paramBlock: ParmBlkPtr; async: BOOLEAN) : OSErr;
  13648.  
  13649. Trap macro  _Create
  13650.  
  13651. Parameter block
  13652.     —>  12  ioCompletion    pointer
  13653.     <—  16  ioResult        word
  13654.     —>  18  ioNamePtr       pointer
  13655.     —>  22  ioVRefNum       word
  13656.     —>  26  ioFVersNum      byte
  13657.  
  13658.     PBCreate creates a new file (both forks) having the name pointed to
  13659. by ioNamePtr (and on flat volumes, the version number ioVersNum) on the
  13660. volume specified by ioVRefNum. The new file is unlocked and empty. The
  13661. date and time of its creation and last modification are set to the
  13662. current date and time. If the file created isn’t temporary (that is, if
  13663. it will exist after the application terminates), the application should
  13664. call PBSetFInfo (after PBCreate) to fill in the information needed by
  13665. the Finder.
  13666. ________________________________________________________________________
  13667.  
  13668. Assembly-language note:  If a desk accessory creates a file, it should
  13669. always create it in the directory containing the system folder. The
  13670. working directory reference number for this directory is stored in the
  13671. global variable BootDrive; you can pass it in ioVRefNum.
  13672. ________________________________________________________________________
  13673.  
  13674. Result codes    noErr       No error
  13675.                 bdNamErr    Bad file name
  13676.                 dupFNErr    Duplicate file name and version
  13677.                 dirFulErr   File directory full
  13678.                 extFSErr    External file system
  13679.                 ioErr       I/O error
  13680.                 nsvErr      No such volume
  13681.                 vLckdErr    Software volume lock
  13682.                 wPrErr      Hardware volume lock
  13683. \ PBHCreate
  13684. 17
  13685. Function PBHCreate (paramBlock: HParmBlkPtr; async: BOOLEAN) : OSErr;
  13686.  
  13687. Trap macro  _HCreate
  13688.  
  13689. Parameter block
  13690.     —>  12  ioCompletion    pointer
  13691.     <—  16  ioResult        word
  13692.     —>  18  ioNamePtr       pointer
  13693.     —>  22  ioVRefNum       word
  13694.     —>  48  ioDirID         long word
  13695.  
  13696.     PBHCreate is identical to PBCreate except that it accepts a
  13697. directory ID in ioDirID.
  13698.  
  13699. Note:  To create a directory instead of a file, call PBDirCreate.
  13700.  
  13701. Result codes    noErr       No error
  13702.                 bdNamErr    Bad file name
  13703.                 dupFNErr    Duplicate file name and version
  13704.                 dirFulErr   File directory full
  13705.                 dirNFErr    Directory not found or incomplete pathname
  13706.                 extFSErr    External file system
  13707.                 ioErr       I/O error
  13708.                 nsvErr      No such volume
  13709.                 vLckdErr    Software volume lock
  13710.                 wPrErr      Hardware volume lock
  13711. \ PBDirCreate
  13712. 17
  13713. Function PBDirCreate (paramBlock: HParmBlkPtr; async: BOOLEAN): OSErr;
  13714.  
  13715. Trap macro  _DirCreate
  13716.  
  13717. Parameter block
  13718.     —>  12  ioCompletion    pointer
  13719.     <—  16  ioResult        word
  13720.     <–> 18  ioNamePtr       pointer
  13721.     —>  22  ioVRefNum       word
  13722.     <–> 48  ioDirID         long word
  13723.  
  13724.     PBDirCreate is identical to PBHCreate except that it creates a new
  13725. directory instead of a file. You can specify the parent of the
  13726. directory to be created in ioDirID; if it’s 0, the new directory will be
  13727. placed in the root directory. The directory ID of the new directory is
  13728. returned in ioDirID.
  13729.  
  13730. Warning:  PBDirCreate operates only with the hierarchical version of the
  13731.           File Manager; if used on a Macintosh equipped only with the
  13732.           64K ROM version of the File Manager, it will generate a system
  13733.           error.
  13734.  
  13735. Result codes    noErr       No error
  13736.                 bdNamErr    Bad file name
  13737.                 dupFNErr    Duplicate file name and version
  13738.                 dirFulErr   File directory full
  13739.                 dirNFErr    Directory not found or incomplete pathname
  13740.                 extFSErr    External file system
  13741.                 ioErr       I/O error
  13742.                 nsvErr      No such volume
  13743.                 vLckdErr    Software volume lock
  13744.                 wPrErr      Hardware volume lock
  13745.  
  13746. \ PBDelete
  13747. 17
  13748. Function PBDelete (paramBlock: ParmBlkPtr; async: BOOLEAN) : OSErr;
  13749.  
  13750. Trap macro  _Delete
  13751.  
  13752. Parameter block
  13753.     —>  12  ioCompletion    pointer
  13754.     <—  16  ioResult        word
  13755.     —>  18  ioNamePtr       pointer
  13756.     —>  22  ioVRefNum       word
  13757.     —>  26  ioFVersNum      byte
  13758.  
  13759.     PBDelete removes the closed file having the name pointed to by
  13760. ioNamePtr (and on flat volumes, the version number ioVersNum) from the
  13761. volume pointed to by ioVRefNum. PBHDelete can be used to delete an
  13762. empty directory as well.
  13763.  
  13764. Note:  This function will delete both forks of the file.
  13765.  
  13766. Result codes    noErr       No error
  13767.                 bdNamErr    Bad file name
  13768.                 extFSErr    External file system
  13769.                 fBsyErr     File busy, directory not empty, or working
  13770.                             directory control block open
  13771.                 fLckdErr    File locked
  13772.                 fnfErr      File not found
  13773.                 nsvErr      No such volume
  13774.                 ioErr       I/O error
  13775.                 vLckdErr    Software volume lock
  13776.                 wPrErr      Hardware volume lock
  13777. \ PBHDelete
  13778. 17
  13779. Function PBHDelete (paramBlock: HParmBlkPtr; async: BOOLEAN) : OSErr;
  13780.  
  13781. Trap macro  _HDelete
  13782.  
  13783. Parameter block
  13784.     —>  12  ioCompletion    pointer
  13785.     <—  16  ioResult        word
  13786.     —>  18  ioNamePtr       pointer
  13787.     —>  22  ioVRefNum       word
  13788.     —>  48  ioDirID         long word
  13789.  
  13790.     PBHDelete is identical to PBDelete except that it accepts a
  13791. directory ID in ioDirID. PBHDelete can be used to delete an empty
  13792. directory as well.
  13793.  
  13794. Result codes    noErr       No error
  13795.                 bdNamErr    Bad file name
  13796.                 dirNFErr    Directory not found or incomplete pathname
  13797.                 extFSErr    External file system
  13798.                 fBsyErr     File busy, directory not empty,
  13799.                             or working directory control block open
  13800.                 fLckdErr    File locked
  13801.                 fnfErr      File not found
  13802.                 nsvErr      No such volume
  13803.                 ioErr       I/O error
  13804.                 vLckdErr    Software volume lock
  13805.                 wPrErr      Hardware volume lock
  13806. \ PBGetFInfo
  13807. 17
  13808. Function PBGetFInfo (paramBlock: ParmBlkPtr; async: BOOLEAN) : OSErr;
  13809.  
  13810. Trap macro  _GetFileInfo
  13811.  
  13812. Parameter block
  13813.     —>  12  ioCompletion    pointer
  13814.     <—  16  ioResult        word
  13815.     <–> 18  ioNamePtr       pointer
  13816.     —>  22  ioVRefNum       word
  13817.     <—  24  ioFRefNum       word
  13818.     —>  26  ioFVersNum      byte
  13819.     —>  28  ioFDirIndex     word
  13820.     <—  30  ioFlAttrib      byte
  13821.     <—  31  ioFlVersNum     byte
  13822.     <—  32  ioFlFndrInfo    16 bytes
  13823.     <—  48  ioFlNum         long word
  13824.     <—  52  ioFlStBlk       word
  13825.     <—  54  ioFlLgLen       long word
  13826.     <—  58  ioFlPyLen       long word
  13827.     <—  62  ioFlRStBlk      word
  13828.     <—  64  ioFlRLgLen      long word
  13829.     <—  68  ioFlRPyLen      long word
  13830.     <—  72  ioFlCrDat       long word
  13831.     <—  76  ioFlMdDat       long word
  13832.  
  13833.     PBGetFInfo returns information about the specified file. If
  13834. ioFDirIndex is positive, the File Manager returns information about the
  13835. file whose directory index is ioFDirIndex on the volume specified by
  13836. ioVRefNum. (See the section “Data Organization on Volumes” if you’re
  13837. interested in using this method.)
  13838.  
  13839. Note:  If a working directory reference number is specified in
  13840.        ioVRefNum, the File Manager returns information about the file
  13841.        whose directory index is ioFDirIndex in the specified directory.
  13842.  
  13843.     If ioFDirIndex is negative or 0, the File Manager returns
  13844. information about the file having the name pointed to by ioNamePtr (and
  13845. on flat volumes, the version number ioFVersNum) on the volume specified
  13846. by ioVRefNum. If the file is open, the reference number of the first
  13847. access path found is returned in ioFRefNum, and the name of the file is
  13848. returned in ioNamePtr (unless ioNamePtr is NIL).
  13849.  
  13850. Result codes    noErr       No error
  13851.                 bdNamErr    Bad file name
  13852.                 extFSErr    External file system
  13853.                 fnfErr      File not found
  13854.                 ioErr       I/O error
  13855.                 nsvErr      No such volume
  13856.                 paramErr    No default volume
  13857. \ PBHGetFInfo
  13858. 17
  13859. Function PBHGetFInfo (paramBlock: HParmBlkPtr; async: BOOLEAN) : OSErr;
  13860.  
  13861. Trap macro  _HGetFileInfo
  13862.  
  13863. Parameter block
  13864.     —>  12  ioCompletion    pointer
  13865.     <—  16  ioResult        word
  13866.     <–> 18  ioNamePtr       pointer
  13867.     —>  22  ioVRefNum       word
  13868.     <—  24  ioFRefNum       word
  13869.     —>  28  ioFDirIndex     word
  13870.     <—  30  ioFlAttrib      byte
  13871.     <—  32  ioFlFndrInfo    16 bytes
  13872.     <–> 48  ioDirID         long word
  13873.     <—  52  ioFlStBlk       word
  13874.     <—  54  ioFlLgLen       long word
  13875.     <—  58  ioFlPyLen       long word
  13876.     <—  62  ioFlRStBlk      word
  13877.     <—  64  ioFlRLgLen      long word
  13878.     <—  68  ioFlRPyLen      long word
  13879.     <—  72  ioFlCrDat       long word
  13880.     <—  76  ioFlMdDat       long word
  13881.  
  13882.     PBHGetFInfo is identical to PBGetFInfo except that it accepts a
  13883. directory ID in ioDirID.
  13884.  
  13885. Result codes    noErr       No error
  13886.                 bdNamErr    Bad file name
  13887.                 dirNFErr    Directory not found or incomplete pathname
  13888.                 extFSErr    External file system
  13889.                 fnfErr      File not found
  13890.                 ioErr       I/O error
  13891.                 nsvErr      No such volume
  13892.                 paramErr    No default volume
  13893. \ PBSetFInfo
  13894. 17
  13895. Function PBSetFInfo (paramBlock: ParmBlkPtr; async: BOOLEAN) : OSErr;
  13896.  
  13897. Trap macro  _SetFileInfo
  13898.  
  13899. Parameter block
  13900.     —>  12  ioCompletion    pointer
  13901.     <—  16  ioResult        word
  13902.     —>  18  ioNamePtr       pointer
  13903.     —>  22  ioVRefNum       word
  13904.     —>  26  ioFVersNum      byte
  13905.     —>  32  ioFlFndrInfo    16 bytes
  13906.     —>  72  ioFlCrDat       long word
  13907.     —>  76  ioFlMdDat       long word
  13908.  
  13909.     PBSetFInfo sets information (including the date and time of creation
  13910. and modification, and information needed by the Finder) about the file
  13911. having the name pointed to by ioNamePtr (and on flat volumes, the
  13912. version number ioFVersNum) on the volume specified by ioVRefNum. You
  13913. should call PBGetFInfo just before PBSetFInfo, so the current
  13914. information is present in the parameter block.
  13915.  
  13916. Result codes    noErr       No error
  13917.                 bdNamErr    Bad file name
  13918.                 extFSErr    External file system
  13919.                 fLckdErr    File locked
  13920.                 fnfErr      File not found
  13921.                 ioErr       I/O error
  13922.                 nsvErr      No such volume
  13923.                 vLckdErr    Software volume lock
  13924.                 wPrErr      Hardware volume lock
  13925. \ PBHSetFInfo
  13926. 17
  13927. Function PBHSetFInfo (paramBlock: HParmBlkPtr; async: BOOLEAN) : OSErr;
  13928.  
  13929. Trap macro  _HSetFileInfo
  13930.  
  13931. Parameter block
  13932.     —>  12  ioCompletion    pointer
  13933.     <—  16  ioResult        word
  13934.     —>  18  ioNamePtr       pointer
  13935.     —>  22  ioVRefNum       word
  13936.     —>  32  ioFlFndrInfo    16 bytes
  13937.     —>  48  ioDirID         long word
  13938.     —>  72  ioFlCrDat       long word
  13939.     —>  76  ioFlMdDat       long word
  13940.  
  13941.     PBHSetFInfo is identical to PBSetFInfo except that it accepts a
  13942. directory ID in ioDirID.
  13943.  
  13944. Result codes    noErr       No error
  13945.                 bdNamErr    Bad file name
  13946.                 dirNFErr    Directory not found or incomplete pathname
  13947.                 extFSErr    External file system
  13948.                 fLckdErr    File locked
  13949.                 fnfErr      File not found
  13950.                 ioErr       I/O error
  13951.                 nsvErr      No such volume
  13952.                 vLckdErr    Software volume lock
  13953.                 wPrErr      Hardware volume lock
  13954. \ PBSetFLock
  13955. 17
  13956. Function PBSetFLock (paramBlock: ParmBlkPtr; async: BOOLEAN) : OSErr;
  13957.  
  13958. Trap macro  _SetFilLock
  13959.  
  13960. Parameter block
  13961.     —>  12  ioCompletion    pointer
  13962.     <—  16  ioResult        word
  13963.     —>  18  ioNamePtr       pointer
  13964.     —>  22  ioVRefNum       word
  13965.     —>  26  ioFVersNum      byte
  13966.  
  13967.     PBSetFLock locks the file having the name pointed to by ioNamePtr
  13968. (and on flat volumes, the version number ioFVersNum) on the volume
  13969. specified by ioVRefNum. Access paths currently in use aren’t affected.
  13970.  
  13971. Result codes    noErr       No error
  13972.                 extFSErr    External file system
  13973.                 fnfErr      File not found
  13974.                 ioErr       I/O error
  13975.                 nsvErr      No such volume
  13976.                 vLckdErr    Software volume lock
  13977.                 wPrErr      Hardware volume lock
  13978.  
  13979. \ PBHSetFLock
  13980. 17
  13981. Function PBHSetFLock (paramBlock: HParmBlkPtr; async: BOOLEAN) : OSErr;
  13982.  
  13983. Trap macro  _HSetFLock
  13984.  
  13985. Parameter block
  13986.     —>  12  ioCompletion    pointer
  13987.     <—  16  ioResult        word
  13988.     —>  18  ioNamePtr       pointer
  13989.     —>  22  ioVRefNum       word
  13990.     —>  48  ioDirID         long word
  13991.  
  13992.     PBHSetFLock is identical to PBSetFLock except that it accepts a
  13993. directory ID in ioDirID.
  13994.  
  13995. Result codes    noErr       No error
  13996.                 dirNFErr    Directory not found or incomplete pathname
  13997.                 extFSErr    External file system
  13998.                 fnfErr      File not found
  13999.                 ioErr       I/O error
  14000.                 nsvErr      No such volume
  14001.                 vLckdErr    Software volume lock
  14002.                 wPrErr      Hardware volume lock
  14003. \ PBRstFLock
  14004. 17
  14005. Function PBRstFLock (paramBlock: ParmBlkPtr; async: BOOLEAN) : OSErr;
  14006.  
  14007. Trap macro  _RstFilLock
  14008.  
  14009. Parameter block
  14010.     —>  12  ioCompletion    pointer
  14011.     <—  16  ioResult        word
  14012.     —>  18  ioNamePtr       pointer
  14013.     —>  22  ioVRefNum       word
  14014.     —>  26  ioFVersNum      byte
  14015.  
  14016.     PBRstFLock unlocks the file having the name pointed to by ioNamePtr
  14017. (and on flat volumes, the version number ioFVersNum) on the volume
  14018. specified by ioVRefNum. Access paths currently in use aren’t affected.
  14019.  
  14020. Result codes    noErr       No error
  14021.                 extFSErr    External file system
  14022.                 fnfErr      File not found
  14023.                 ioErr       I/O error
  14024.                 nsvErr      No such volume
  14025.                 vLckdErr    Software volume lock
  14026.                 wPrErr      Hardware volume lock
  14027.  
  14028. \ PBHRstFLock
  14029. 17
  14030. Function PBHRstFLock (paramBlock: HParmBlkPtr; async: BOOLEAN) : OSErr;
  14031.  
  14032. Trap macro  _HRstFLock
  14033.  
  14034. Parameter block
  14035.     —>  12  ioCompletion    pointer
  14036.     <—  16  ioResult        word
  14037.     —>  18  ioNamePtr       pointer
  14038.     —>  22  ioVRefNum       word
  14039.     —>  48  ioDirID         long word
  14040.  
  14041.     PBHRstFLock is identical to PBRstFLock except that it accepts a
  14042. directory ID in ioDirID.
  14043.  
  14044. Result codes    noErr       No error
  14045.                 dirNFErr    Directory not found or incomplete pathname
  14046.                 extFSErr    External file system
  14047.                 fnfErr      File not found
  14048.                 ioErr       I/O error
  14049.                 nsvErr      No such volume
  14050.                 vLckdErr    Software volume lock
  14051.                 wPrErr      Hardware volume lock
  14052.  
  14053. \ PBSetFVers
  14054. 17
  14055. Function PBSetFVers (paramBlock: ParmBlkPtr; async: BOOLEAN) : OSErr;
  14056.  
  14057. Trap macro  _SetFilType
  14058.  
  14059. Parameter block
  14060.     —>  12  ioCompletion    pointer
  14061.     <—  16  ioResult        word
  14062.     —>  18  ioNamePtr       pointer
  14063.     —>  22  ioVRefNum       word
  14064.     —>  26  ioVersNum       byte
  14065.     —>  28  ioMisc          byte
  14066.  
  14067.     PBSetFVers has no effect on hierarchical volumes. On flat volumes,
  14068. PBSetFVers changes the version number of the file having the name
  14069. pointed to by ioNamePtr and version number ioVersNum, on the volume
  14070. specified by ioVRefNum, to the version number stored in the high-order
  14071. byte of ioMisc. Access paths currently in use aren’t affected.
  14072.  
  14073. Result codes    noErr           No error
  14074.                 bdNamErr        Bad file name
  14075.                 dupFNErr        Duplicate file name and version
  14076.                 extFSErr        External file system
  14077.                 fLckdErr        File locked
  14078.                 fnfErr          File not found
  14079.                 nsvErr          No such volume
  14080.                 ioErr           I/O error
  14081.                 paramErr        No default volume
  14082.                 vLckdErr        Software volume lock
  14083.                 wPrErr          Hardware volume lock
  14084.                 wrgVolTypErr    Attempt to perform hierarchical
  14085.                                 operation on a flat volume
  14086. \ PBRename
  14087. 17
  14088. Function PBRename (paramBlock: ParmBlkPtr; async: BOOLEAN) : OSErr;
  14089.  
  14090. Trap macro  _Rename
  14091.  
  14092. Parameter block
  14093.     —>  12  ioCompletion    pointer
  14094.     <—  16  ioResult        word
  14095.     —>  18  ioNamePtr       pointer
  14096.     —>  22  ioVRefNum       word
  14097.     —>  26  ioVersNum       byte
  14098.     —>  28  ioMisc          pointer
  14099.  
  14100.     Given a pointer to a file name in ioNamePtr (and on flat volumes, a
  14101. version number in ioVersNum), PBRename changes the name of the file to
  14102. the name pointed to by ioMisc. (If the name pointed to by ioNamePtr
  14103. contains one or more colons, so must the name pointed to by ioMisc.)
  14104. Access paths currently in use aren’t affected. Given a pointer to a
  14105. volume name in ioNamePtr or a volume reference number in ioVRefNum, it
  14106. changes the name of the volume to the name pointed to by ioMisc. If a
  14107. volume to be renamed is specified by its volume reference number,
  14108. ioNamePtr can be NIL.
  14109.  
  14110. Warning:  If a volume to be renamed is specified by its volume name, be
  14111.           sure that it ends with a colon, or Rename will consider it a
  14112.           file name.
  14113.  
  14114. Result codes    noErr       No error
  14115.                 bdNamErr    Bad file name
  14116.                 dirFulErr   File directory full
  14117.                 dupFNErr    Duplicate file name and version
  14118.                 extFSErr    External file system
  14119.                 fLckdErr    File locked
  14120.                 fnfErr      File not found
  14121.                 fsRnErr     Problem during rename
  14122.                 ioErr       I/O error
  14123.                 nsvErr      No such volume
  14124.                 paramErr    No default volume
  14125.                 vLckdErr    Software volume lock
  14126.                 wPrErr      Hardware volume lock
  14127. \ PBHRename
  14128. 17
  14129. Function PBHRename (paramBlock: HParmBlkPtr; async: BOOLEAN) : OSErr;
  14130.  
  14131. Trap macro  _HRename
  14132.  
  14133. Parameter block
  14134.     —>  12  ioCompletion    pointer
  14135.     <—  16  ioResult        word
  14136.     —>  18  ioNamePtr       pointer
  14137.     —>  22  ioVRefNum       word
  14138.     —>  28  ioMisc      pointer
  14139.     —>  48  ioDirID     long word
  14140.  
  14141.     PBHRename is identical to PBRename except that it accepts a
  14142. directory ID in ioDirID and can be used to rename directories as well as
  14143. files and volumes. Given a pointer to the name of a file or directory
  14144. in ioNamePtr, PBHRename changes it to the name pointed to by ioMisc.
  14145. Given a pointer to a volume name in ioNamePtr or a volume reference
  14146. number in ioVRefNum, it changes the name of the volume to the name
  14147. pointed to by ioMisc.
  14148.  
  14149. Warning:  PBHRename cannot be used to change the directory a file is in.
  14150.  
  14151. Result codes    noErr       No error
  14152.                 bdNamErr    Bad file name
  14153.                 dirFulErr   File directory full
  14154.                 dirNFErr    Directory not found or incomplete pathname
  14155.                 dupFNErr    Duplicate file name and version
  14156.                 extFSErr    External file system
  14157.                 fLckdErr    File locked
  14158.                 fnfErr      File not found
  14159.                 fsRnErr     Problem during rename
  14160.                 ioErr       I/O error
  14161.                 nsvErr      No such volume
  14162.                 paramErr    No default volume
  14163.                 vLckdErr    Software volume lock
  14164.                 wPrErr      Hardware volume lock
  14165. \ PBGetCatInfo
  14166. 17
  14167. Function PBGetCatInfo (paramBlock: CInfoPBPtr; async: BOOLEAN): OSErr;
  14168.  
  14169. Trap macro  _GetCatInfo
  14170.  
  14171. Parameter block
  14172.     Files:                              Directories:
  14173.     —>  12  ioCompletion    pointer —>  12  ioCompletion    pointer
  14174.     <—  16  ioResult        word    <—  16  ioResult        word
  14175.     <–> 18  ioNamePtr       pointer <–> 18  ioNamePtr       pointer
  14176.     —>  22  ioVRefNum       word    —>  22  ioVRefNum       word
  14177.     <—  24  ioFRefNum       word    <—  24  ioFRefNum       word
  14178.     —>  28  ioFDirIndex     word    —>  28  ioFDirIndex     word
  14179.     <—  30  ioFlAttrib      byte    <—  30  ioFlAttrib      byte
  14180.                                     <—  31  ioACUser    byte
  14181.     <—  32  ioFlFndrInfo    16 bytes<—  32  ioDrUsrWds      16 bytes
  14182.     <–> 48  ioDirID         long    <–> 48  ioDrDirID       long
  14183.     <—  52  ioFlStBlk       word    <—  52  ioDrNmFls       word
  14184.     <—  54  ioFlLgLen       long
  14185.     <—  58  ioFlPyLen       long
  14186.     <—  62  ioFlRStBlk      word
  14187.     <—  64  ioFlRLgLen      long
  14188.     <—  68  ioFlRPyLen      long
  14189.     <—  72  ioFlCrDat       long    <—  72  ioDrCrDat       long
  14190.     <—  76  ioFlMdDat       long    <—  76  ioDrMdDat       long
  14191.     <—  80  ioFlBkDat       long    <—  80  ioDrBkDat       long
  14192.     <—  84  ioFlXFndrInfo   16 bytes<—  84  ioDrFndrInfo    16 bytes
  14193.     <—  100 ioFlParID       long    <—  100 ioDrParID       long
  14194.     <—  104 ioFlClpSiz      long
  14195.  
  14196.     PBGetCatInfo gets information about the files and directories in a
  14197. file catalog. To determine whether the information is for a file or a
  14198. directory, test bit 4 of ioFlAttrib, as described in the section
  14199. “CInfoPBRec”. The information that’s returned for files is shown in the
  14200. left column, and the corresponding information for directories is shown
  14201. in the right column.
  14202.  
  14203.     If ioFDirIndex is positive, the File Manager returns information
  14204. about the file or directory whose directory index is ioFDirIndex in the
  14205. directory specified by ioVRefNum (this will be the root directory if a
  14206. volume reference number is provided).
  14207.  
  14208.     If ioFDirIndex is 0, the File Manager returns information about the
  14209. file or directory specified by ioNamePtr, in the directory specified by
  14210. ioVRefNum (again, this will be the root directory if a volume reference
  14211. number is provided).
  14212.  
  14213.     If ioFDirIndex is negative, the File Manager ignores ioNamePtr and
  14214. returns information about the directory specified by ioDirID.
  14215.  
  14216.     With files, PBGetCatInfo is similar to PBHGetFileInfo but returns
  14217. some additional information. If the file is open, the reference number
  14218. of the first access path found is returned in ioFRefNum, and the name of
  14219. the file is returned in ioNamePtr (unless ioNamePtr is NIL).
  14220.  
  14221.     For server volume directories, in addition to the normal return parameters the ioACUser field returns the user’s access rights in the following format:
  14222.  
  14223.     Bit 7   if set, user is not the owner of the directory.
  14224.             if clear, user is the owner of the directory.
  14225.         6–3 Reserved; this is returned set to zero.
  14226.         2   If set, user does not have Make Changes privileges to the
  14227.             directory. If clear, user has Make Changes privileges to
  14228.             the directory.
  14229.         1   If set, user does not have See Files privileges to the
  14230.             directory. If clear, user has See Files privileges to the
  14231.             directory.
  14232.         0   If set, user does not have See Folders privileges to the
  14233.             directory. If clear, user has See Folders privileges to
  14234.             the directory.
  14235.  
  14236.     For example, if ioACUser returns zero for a given server volume directory, you know that the user is the owner of the directory and has complete privileges to it.
  14237.  
  14238. Result codes    noErr       No error
  14239.                 bdNamErr    Bad file name
  14240.                 dirNFErr    Directory not found or incomplete pathname
  14241.                 extFSErr    External file system
  14242.                 fnfErr      File not found
  14243.                 ioErr       I/O error
  14244.                 nsvErr      No such volume
  14245.                 paramErr    No default volume
  14246. \ PBSetCatInfo
  14247. 17
  14248. Function PBSetCatInfo (paramBlock: CInfoPBPtr; async: BOOLEAN) : OSErr;
  14249.  
  14250. Trap macro  _SetCatInfo
  14251.  
  14252. Parameter block
  14253.     Files:                          Directories:
  14254.     —>  12  ioCompletion    pointer —>  12  ioCompletion    pointer
  14255.     <—  16  ioResult        word    <—  16  ioResult        word
  14256.     <–> 18  ioNamePtr       pointer <–> 18  ioNamePtr       pointer
  14257.     —>  22  ioVRefNum       word    —>  22  ioVRefNum       word
  14258.     —>  30  ioFlAttrib      byte    —>  30  ioFlAttrib      byte
  14259.     —>  32  ioFlFndrInfo    16 bytes—>  32  ioDrUsrWds      16 bytes
  14260.     —>  48  ioDirID         long    —>  48  ioDrDirID       long
  14261.     —>  72  ioFlCrDat       long    —>  72  ioDrCrDat       long
  14262.     —>  76  ioFlMdDat       long    —>  76  ioDrMdDat       long
  14263.     —>  80  ioFlBkDat       long    —>  80  ioDrBkDat       long
  14264.     —>  84  ioFlXFndrInfo   16 bytes—>  84  ioDrFndrInfo    16 bytes
  14265.     —>  104 ioFlClpSiz      long
  14266.  
  14267.     PBSetCatInfo sets information about the files and directories in a
  14268. catalog. With files, it’s similar to PBHSetFileInfo but lets you set
  14269. some additional information. The information that can be set for files
  14270. is shown in the left column, and the corresponding information for
  14271. directories is shown in the right column.
  14272.  
  14273. Result codes    noErr       No error
  14274.                 bdNamErr    Bad file name
  14275.                 dirNFErr    Directory not found or incomplete pathname
  14276.                 extFSErr    External file system
  14277.                 fnfErr      File not found
  14278.                 ioErr       I/O error
  14279.                 nsvErr      No such volume
  14280.                 paramErr    No default volume
  14281. \ PBCatMove
  14282. 17
  14283. Function PBCatMove (paramBlock: CMovePBPtr; async: BOOLEAN) : OSErr;
  14284.  
  14285. Trap macro  _CatMove
  14286.  
  14287. Parameter block
  14288.     —>  12  ioCompletion    pointer
  14289.     <—  16  ioResult        word
  14290.     —>  18  ioNamePtr       pointer
  14291.     —>  22  ioVRefNum       word
  14292.     —>  28  ioNewName       pointer
  14293.     —>  36  ioNewDirID      long word
  14294.     —>  48  ioDirID         long word
  14295.  
  14296.     PBCatMove moves files or directories from one directory to another.
  14297. The name of the file or directory to be moved is pointed to by
  14298. ioNamePtr; ioVRefNum contains either the volume reference number or
  14299. working directory reference number. A directory ID can be specified in
  14300. ioDirID. The name and directory ID of the directory to which the file
  14301. or directory is to be moved are specified by ioNewName and ioNewDirID.
  14302.  
  14303.     PBCatMove is strictly a file catalog operation; it does not actually
  14304. change the location of the file or directory on the disk. PBCatMove
  14305. cannot move a file or directory to another volume (that is, ioVRefNum is
  14306. used in specifying both the source and the destination). It also cannot
  14307. be used to rename files or directories; for that, use PBHRename.
  14308.  
  14309. Result codes    noErr       No error
  14310.                 badMovErr   Attempt to move into offspring
  14311.                 bdNamErr    Bad file name or attempt to move into a file
  14312.                 dupFNErr    Duplicate file name and version
  14313.                 fnfErr      File not found
  14314.                 ioErr       I/O error
  14315.                 nsvErr      No such volume
  14316.                 paramErr    No default volume
  14317.                 vLckdErr    Software volume lock
  14318.                 wPrErr      Hardware volume lock
  14319. \ PBOpenWD
  14320. 17
  14321. Function PBOpenWD (paramBlock: WDPBPtr; async: BOOLEAN) : OSErr;
  14322.  
  14323. Trap macro  _OpenWD
  14324.  
  14325. Parameter block
  14326.     —>  12  ioCompletion    pointer
  14327.     <—  16  ioResult        word
  14328.     —>  18  ioNamePtr       pointer
  14329.     <–> 22  ioVRefNum       word
  14330.     —>  28  ioWDProcID      long word
  14331.     —>  48  ioWDDirID       long word
  14332.  
  14333.     PBOpenWD takes the directory specified by ioVRefNum, ioWDDirID, and
  14334. ioWDProcID and makes it a working directory. (You can also specify the
  14335. directory using a combination of partial pathname and directory ID.)  It
  14336. returns a working directory reference number in ioVRefNum that can be
  14337. used in subsequent calls.
  14338.  
  14339.     If a given directory has already been made a working directory using
  14340. the same ioWDProcID, no new working directory will be opened; instead,
  14341. the existing working directory reference number will be returned. If a
  14342. given directory was already made a working directory using a different
  14343. ioWDProcID, a new working directory reference number is returned.
  14344.  
  14345. Result codes    noErr       No error
  14346.                 tmwdoErr    Too many working directories open
  14347. \ PBCloseWD
  14348. 17
  14349. Function PBCloseWD (paramBlock: WDPBPtr; async: BOOLEAN) : OSErr;
  14350.  
  14351. Trap macro  _CloseWD
  14352.  
  14353. Parameter block
  14354.     —>  12  ioCompletion    pointer
  14355.     <—  16  ioResult        word
  14356.     —>  22  ioVRefNum       word
  14357.  
  14358.     PBCloseWD releases the working directory whose working directory
  14359. reference number is specified in ioVRefNum.
  14360.  
  14361. Note:  If a volume reference number is specified in ioVRefNum, PBCloseWD
  14362.        does nothing.
  14363.  
  14364. Result codes    noErr   No error
  14365.                 nsvErr  No such volume
  14366. \ PBGetWDInfo
  14367. 17
  14368. Function PBGetWDInfo (paramBlock: WDPBPtr; async: BOOLEAN) : OSErr;
  14369.  
  14370. Trap macro  _GetWDInfo
  14371.  
  14372. Parameter block
  14373.     —>  12  ioCompletion    pointer
  14374.     <—  16  ioResult        word
  14375.     <—  18  ioNamePtr       pointer
  14376.     <–> 22  ioVRefNum       word
  14377.     —>  26  ioWDIndex       word
  14378.     <–> 28  ioWDProcID      long word
  14379.     <–> 32  ioWDVRefNum     word
  14380.     <—  48  ioWDDirID       long word
  14381.  
  14382.     PBGetWDInfo returns information about the specified working
  14383. directory. The working directory can be specified either by its working
  14384. directory reference number in ioVRefNum (in which case ioWDIndex should
  14385. be 0), or by its index number in ioWDIndex. In the latter case, if
  14386. ioVRefNum is nonzero, it’s interpreted as a volume specification (volume
  14387. reference number or drive number), and only working directories on that
  14388. volume are indexed.
  14389.  
  14390.     IOWDVRefNum always returns the volume reference number. IOVRefNum
  14391. returns a working directory reference number when a working directory
  14392. reference number is passed in that field; otherwise, it returns a volume
  14393. reference number. The volume name is returned in ioNamePtr.
  14394.  
  14395.     If IOWDProcID is nonzero, only working directories with that
  14396. identifier are indexed; otherwise all working directories are indexed.
  14397.  
  14398. Result codes    noErr   No error
  14399.                 nsvErr  No such volume
  14400. \ PrOpen
  14401. 18
  14402. Procedure PrOpen;
  14403.  
  14404.     PrOpen prepares the Printing Manager for use. It opens the Printer
  14405. Driver and the printer resource file. If either of these items is
  14406. missing, or if the printer resource file is not properly formed, PrOpen
  14407. will do nothing, and PrError will return a Resource Manager result
  14408. code.
  14409. \ PrClose
  14410. 18
  14411. Procedure PrClose;
  14412.  
  14413.     PrClose releases the memory used by the Printing Manager. It closes
  14414. the printer resource file, allowing the file's resource map to be
  14415. removed from memory. It *** currently *** doesn't close the Printer
  14416. Driver, however, since the driver may have been opened before the
  14417. PrOpen call was issued.
  14418. \ PrintDefault
  14419. 18
  14420. Procedure PrintDefault (hPrint: THPrint);
  14421.  
  14422.     PrintDefault fills the fields of a print record with the current
  14423. default values stored in the printer resource file. HPrint is a handle
  14424. to the record, which may be a new print record that you've just
  14425. allocated or an existing one (from a document, for example).
  14426. \ PrValidate
  14427. 18
  14428. Function PrValidate (hPrint: THPrint) : BOOLEAN;
  14429.  
  14430.     PrValidate checks the contents of a print record for compatibility
  14431. with the current version of the Printing Manager and with the installed
  14432. printer. If the record is valid, the function returns FALSE (no
  14433. change); if invalid, the record is adjusted to the current default
  14434. values, taken from the printer resource file, and the function returns
  14435. TRUE.
  14436.  
  14437.     PrValidate also updates the print record to reflect the current
  14438. settings in the style and job subrecords. These changes have no effect
  14439. on the function's Boolean result.
  14440. \ PrStlDialog
  14441. 18
  14442. Function PrStlDialog (hPrint: THPrint) : BOOLEAN;
  14443.  
  14444.     PrStlDialog conducts a style dialog with the user to determine the
  14445. paper size and paper orientation being used. The initial settings
  14446. displayed in the dialog box are taken from the current values in the
  14447. print record. If the user confirms the dialog, the results of the
  14448. dialog are saved in the print record and the function returns TRUE;
  14449. otherwise the print record is left unchanged and the function returns
  14450. FALSE.
  14451.  
  14452. (note)
  14453.     If the print record was taken from a document, you should
  14454.     update its contents in the document's file if PrStlDialog
  14455.     returns TRUE. This makes the results of the style dialog
  14456.     "stick" to the document.
  14457. \ PrJobDialog
  14458. 18
  14459. Function PrJobDialog (hPrint: THPrint) : BOOLEAN;
  14460.  
  14461.     PrJobDialog conducts a job dialog with the user to determine the
  14462. printing quality, number of pages to print, and so on. The initial
  14463. settings displayed in the dialog box are taken from the current values
  14464. in the print reord. If the user confirms the dialog, both the print
  14465. record and the printer resource file are updated (so that the user's
  14466. choices "stick" to the printer) and the function returns TRUE;
  14467. otherwise the print record and printer resource file are left unchanged
  14468. and the function returns FALSE.
  14469.  
  14470. (note)
  14471.     If the job dialog is associated with your application's
  14472.     Print command, you should proceed with the requested
  14473.     printing operation id PrJobDialog returns TRUE. If the
  14474.     print record was taken form a document, you should update
  14475.     its contents in the document's file.
  14476. \ PrJobMerge
  14477. 18
  14478. Procedure PrJobMerge (hPringSrc,hPrintDst: THPrint):
  14479.  
  14480.     PrJobMerge copies the job subrecord from one print record
  14481. (hPrintSrc) to another (hPrintDst) and updates the destination record's
  14482. printer information, band information, and paper rectangle, based on
  14483. information in the job subrecord. This allows the information in the
  14484. job subrecord to be used for a group of related jobs.
  14485. \ PrOpenDoc
  14486. 18
  14487. Function PrOpenDoc (hPrint: THPrint; pPrPort: TPPrPort; pIOBuf: Ptr)
  14488.         : TPPrPort;
  14489.  
  14490.     PrOpenDoc initializes a printing port for use in printing a document
  14491. makes it the current port, and returns pointer to it. HPrint is a
  14492. handle to the print record for this printing operation. The printing
  14493. port is customized for draft printing or spooling, depending on the
  14494. setting of th bJDocLoop field in the job subrecord. For spooling, the
  14495. spool file's name, volume reference number, and version number are
  14496. taken from the job subrecord.
  14497.  
  14498.     PPrPort is a pointer to the storage to be used for the printing
  14499. port. If this parameter is NIL, PrOpenDoc will allocate a new printing
  14500. port for you. Similarly, pIOBuf points to an area of memory to be used
  14501. as an input/output buffer; if it's NIL, PrOpenDoc will use the volume
  14502. buffer for the spool file's volume.
  14503.  
  14504. (note)
  14505.     The pPrPort and pIOBuf parameters are provided because
  14506.     both the printing port and the input/output buffer are
  14507.     nonrelocatable objects. To avoid cluttering the heap
  14508.     with such objects, you have the opportunity to allocate
  14509.     them yourself and pass them to PrOpenDoc. Most of the
  14510.     time you'll just set both of these parameters to NIL.
  14511.  
  14512. (note)
  14513.     Newly created printing ports use the system font (since
  14514.     they're grafPorts), but newly created windows use the
  14515.     application font. Be sure the font you use in the
  14516.     printing port is the same as the font in your application
  14517.     window if yuou want the text in both places to match.
  14518. \ PrOpenPage
  14519. 18
  14520. Procedure PrOpenPage (pPrPort: TPPrPort; pPageFrame: TPRect);
  14521.  
  14522.     PrOpenPage begins a new page in the document associated with the
  14523. given printing port. The page is printed only if it falls within the
  14524. page range designated in the job subrecord.
  14525.  
  14526.     For spooling, the pPageFrame parameter points to a rectangle that
  14527. will be used as the QuickDraw picture frame for this page:
  14528.  
  14529.     TYPE TPRect = ^Rect;
  14530.  
  14531.     When the spool file is later printed, this rectangle will be scaled
  14532. (via the QuickDraw DrawPicture procedure) to coincide with the page
  14533. rectangle in the printer ilnformation subrecord. Unless you want the
  14534. printout to be scaled, you should set pPageFrame to NIL--this uses the
  14535. curret page rectangle as the picture frame, and the page will be
  14536. printed with no scaling.
  14537. \ PrClosePage
  14538. 18
  14539. Procedure PrClosePage (pPrPort: TPPrPort);
  14540.  
  14541.     PrClosePage finishes up the current page of the document associated
  14542. with the given printing port. For draft printing, it ejects the page
  14543. from the printer and, if necessary, alerts the user to insert another;
  14544. for spooling, it closes the picture representing the current page.
  14545. \ PrCloseDoc
  14546. 18
  14547. Procedure PrCloseDoc (pPrPort: TPPrPort);
  14548.  
  14549.     PrCloseDoc finishes up the printing of the document associated with
  14550. the given printing port. For draft printing, it issues a form feed and
  14551. a reset command to the printer; for spooling, it closes the file if the
  14552. spooling was successfully completed or deletes it the file if the
  14553. spooling was unsuccessful.
  14554. \ PrPicFile
  14555. 18
  14556. Procedure PrPicFile (hPrint: THPrint; pPrPort: TPPrPort; pIOBuf: Ptr;
  14557.         pDevBuf: Ptr; VAR prStatus: TPrStatus);
  14558.  
  14559.     PrPicFile images and prints a spool file. HPrint is a handle to the
  14560. print record for this printing operation. The name, volume reference
  14561. number, and version number of the spool file will be taken from the job
  14562. subrecord of this print record. After printing is successfully
  14563. completed, the Printing Manager deletes the spool file from the disk.
  14564.  
  14565.     PPrPort is a pointer to the storage to be used for the printing port
  14566. for this operation. If this parameter is NIL, PrPicFile will allocate
  14567. its own printing port. Similarly, pIOBuf points to an area of memory
  14568. to be used as an input/output buffer for reading the spool file; if
  14569. it's NIL, PrPicFile will use the volume buffer for the spool file's
  14570. volume. PDevBuf points to a similar buffer (the "band buffer") for
  14571. holding the bit image to be printed; ifNIL, PrPicFile will allocate
  14572. its own buffer from the heap. As for PrOpenDoc, you'll normally want
  14573. to set all of these storage parameters to NIL.
  14574.  
  14575. (note)
  14576.     If you provide your own storage for pDevBuf, it has to be
  14577.     big enough to hold the number of bytes indicated by the
  14578.     iDevBytes field of the TPrXInfo subrecord of the print
  14579.     record.
  14580.  
  14581. (warning)
  14582.     Be sure not to pass, in pPrPort, a pointer to the same
  14583.     printing port you received from PrOpenDoc, the one you
  14584.     originally used to spool the file. If that earlier port
  14585.     was allocated by PrOpenDoc itself (that is, if the
  14586.     pPrPort parameter to PrOpenDoc was NIL), then PrCloseDoc
  14587.     will have disposed of the port, making your pointer to it
  14588.     invalid. PrPicFile initializes a fresh printing port of
  14589.     its own; you just provide the storage (or let PrPicFIle
  14590.     allocate it for itself). Of course, if you earlier
  14591.     provided your own storage to PrOpenDoc, there's no reason
  14592.     you can't use the same storage again for PrPicFile.
  14593.  
  14594.     The prStatus parameter is a printer status record that PrPicFile
  14595. will use to report on its progress. Your background procedure (if any)
  14596. can use this record to monitor the state of the printing operation.
  14597. \ PrError
  14598. 18
  14599. Function PrError : INTEGER; [Pascal only]
  14600.  
  14601.     PrError returns the result code returned by the last Printing
  14602. Manager routine. The possible result codes are:
  14603.  
  14604.     CONST noErr       = 0;     {no error}
  14605.           iMemFullErr = -108;  {not enough heap space}
  14606.  
  14607.     and any Resource Manager result code. A result code of iMemFullErr
  14608. means that the Memory Manager was unable to fulfill a memory allocation
  14609. request by the Printing Manager.
  14610. \ PrSetError
  14611. 18
  14612. Procedure PrSetError (iErr: INTEGER); [Pascal Only]
  14613.  
  14614.     PrSetError stores the specified value into the global variable where
  14615. the Printing Manager keeps its result code. The main *** (currently
  14616. the only) *** use of this procedure is for canceling a printing
  14617. operation in progress. To do this, write
  14618.  
  14619.     PrSetError(iPrAbort)
  14620.  
  14621. where iPrAbort is the following predefined constant:
  14622.  
  14623.     CONST iPrAbort = 128;  {result code for halting printing}
  14624. \ PrDrvrOpen
  14625. 18
  14626. Procedure PrDrvrOpen;
  14627.  
  14628.     PrDrvrOpen opens the Printer Driver.
  14629. \ PrDrvrClose
  14630. 18
  14631. Procedure PrDrvrClose;
  14632.  
  14633.     PrDrvrClose closes the Printer Driver.
  14634. \ PrCtlCall
  14635. 18
  14636. Procedure PrCtlCall (iWhichCtl: INTEGER; lParam1,lParam2,lParam3):
  14637.                     LongInt);
  14638.  
  14639.     PrCtlCall calls the Printer Driver's control routine. IWhichCtl
  14640. designates the operation to be performed; the rest of the parameters
  14641. depend on the operation.
  14642. \ PrDrvrDCE
  14643. 18
  14644. Function PrDrvrDCE : Handle;
  14645.  
  14646.     PrDrvrDCE returns a handle to the Printer Driver's device control
  14647. entry.
  14648. \ PrDrvrVers
  14649. 18
  14650. Function PrDrvrVers : INTEGER;
  14651.  
  14652.     PrDrvrVers returns the version number of the Printer Driver in the
  14653. system resource file.
  14654.  
  14655.     The version number of the Printing Manager is available as the
  14656. predefined constant iPrRelease. You may want to compare the result of
  14657. PrDrvrVers with iPrRelease to see if the Printer Driver in the resource
  14658. file is the most recent version.
  14659. \ PrNoPurge
  14660. 18
  14661. Procedure PrNoPurge;
  14662.  
  14663.     PrNoPurge prevents the Printer Driver from being purged from the
  14664. heap.
  14665. \ PrPurge
  14666. 18
  14667. Procedure PrPurge;
  14668.  
  14669.     PrPurge allows the Printer Driver to be purged from the heap.
  14670. \ OpenDriver
  14671. 19
  14672. Function OpenDriver (name: Str255; VAR refNum: INTEGER) : OSErr;
  14673.  
  14674.     OpenDriver opens the device driver specified by name and returns its
  14675. reference number in refNum.
  14676.  
  14677.     Result codes    noErr           No error
  14678.                     badUnitErr      Bad reference number
  14679.                     dInstErr        Couldn't find driver in resource
  14680.                                     file
  14681.                     openErr         Driver cannot perform the
  14682.                                     requested reading or writing
  14683.                     unitEmptyErr    Bad reference number
  14684. \ CloseDriver
  14685. 19
  14686. Function CloseDriver (refNum: INTEGER) : OSErr;
  14687.  
  14688.     CloseDriver closes the device driver having the reference number
  14689. refNum. Any pending I/O is completed, and the memory used by the
  14690. driver is released.
  14691.  
  14692.  
  14693.     Result codes    noErr           No error
  14694.                     badUnitErr      Bad reference number
  14695.                     dRemoveErr      Tried to remove an open driver
  14696.                     unitEmptyErr    Bad reference number
  14697. \ FSRead
  14698. 19
  14699. Function FSRead (refNum: INTEGER; VAR count: LongInt; buffPtr: Ptr) :
  14700.         OSErr;
  14701.  
  14702.     FSRead attempts to read the number of bytes specified by the count
  14703. parameter from the device driver having the reference number refNum,
  14704. and transfer them to the data buffer pointed to by buffPtr. After the
  14705. read operation is completed, the number of bytes actually read is
  14706. returned in the count parameter.
  14707.  
  14708.  
  14709.     Result codes    noErr           No error
  14710.                     badUnitErr      Bad reference number
  14711.                     notOpenErr      Driver isn't open
  14712.                     unitEmptyErr    Bad reference number
  14713.                     readErr         Driver can't respond to Read
  14714.                                     calls
  14715. \ FSWrite
  14716. 19
  14717. Function FSWrite (refNum: INTEGR; VARcount: LongInt; buffPtr: Ptr) :
  14718.                     OSErr;
  14719.  
  14720.     FSWrite attempts to take the number of bytes specified by the count
  14721. parameter from the buffer pointed to by buffPtr and write them to the
  14722. open device driver having the reference number refNum. After the write
  14723. operation is completed, the number of bytes actually written is
  14724. returned in the count parameter.
  14725.  
  14726.     Result codes    noErr           No error
  14727.                     badUnitErr      Bad reference number
  14728.                     notOpenErr      Driver isn't open
  14729.                     unitEmptyErr    Bad reference number
  14730.                     writErr         Driver can't respond to Write
  14731.                                     calls
  14732. \ Control
  14733. 19
  14734. Function COntrol (refNum: INTEGER; csCode: INTEGER; csParam: Ptr):
  14735.         OSErr;
  14736.  
  14737.     Control sends control information to the device driver haaving the
  14738. reference number refNum. The type of information sent is specified by
  14739. csCode, and the ilnformation itself is pointed to by csParam. The
  14740. values passed in csCode and pointed to by csParam depend on the driver
  14741. being called.
  14742.  
  14743.  
  14744.     Result codes    noErr           No error
  14745.                     badUnitErr      Bad reference number
  14746.                     notOpenErr      Driver isn't open
  14747.                     unitEmptyErr    Bad reference number
  14748.                     controlErr      Driver can't respond to this
  14749.                                     Control call
  14750.  
  14751.  
  14752.  
  14753. \ Status
  14754. 19
  14755. Function Status (refNum: INTEGER; csCode: INTEGER; csParam: Ptr) :
  14756.         OSErr;
  14757.  
  14758.     Status returns status information about the device driver having the
  14759. reference number refNum. The type of information returned is specified
  14760. by csCode, and the information itself is pointed to by csParam. The
  14761. values passed in csCode and pointed to by csParam depend on the driver
  14762. being called.
  14763.  
  14764.     Result codes    noErr           No error
  14765.                     badUnitErr      Bad reference number
  14766.                     notOpenErr      Driver isn't open
  14767.                     unitEmptyErr    Bad reference number
  14768.                     statusErr       Driver can't respond to this
  14769.                                     Status call
  14770. \ KillIO
  14771. 19
  14772. Function KillIO (refNum: INTEGER) : OSErr;
  14773.  
  14774.     KillIO terminates all current and pending I/O with the device driver
  14775. having the reference number refNum.
  14776.  
  14777.     Result codes    noErr           No error
  14778.                     badUnitErr      Bad reference number
  14779.                     unitEmptyErr    Bad reference number
  14780.                     controlErr      Driver can't respond to KillIO
  14781.                                     calls
  14782.  
  14783. (note)
  14784.     KillIO is actually a special type of PBControl call, and
  14785.     all information aabout PBControl calls applies equally to
  14786.     KillIO.
  14787. \ PBOpen
  14788. 19
  14789. Function PBOpen (paramBlock: ParmBlkPtr; async: BOOLEAN) : OSErr;
  14790.  
  14791.     Trap macro  _Open
  14792.  
  14793.     Parameter block
  14794.         --> 12  ioCompletion    pointer
  14795.         <-- 16  ioResult    word
  14796.         --> 18  ioNamePtr   pointer
  14797.         <-- 24  ioRefNum    word
  14798.         --> 27  ioPermssn   byte
  14799.  
  14800.     Result codes    noErr           No error
  14801.                     badUnitErr      Bad reference number
  14802.                     dInstErr        Couldn't find driver in resource
  14803.                                     file
  14804.                     openErr         Driver cannot perform the
  14805.                                     requested reading or writing
  14806.                     unitEmptyErr    Bad reference number
  14807.  
  14808.  
  14809.     PBOpen opens the device driver specified by ioNamePtr and returns
  14810. its reference number in ioRefNum. IOPermssn specifies the requested
  14811. read/write permission.
  14812. \ PBClose
  14813. 19
  14814. Function PBCLose (paramBlock: ParmBlkPtr; async: BOOLEAN) : OSErr;
  14815.  
  14816.     Trap macro  _Close
  14817.  
  14818.     Parameter block
  14819.         --> 12  ioCompletion    pointer
  14820.         <-- 16  ioResult    word
  14821.         --> 24  ioRefNum    word
  14822.  
  14823.     Result codes    noErr           No error
  14824.                     badUnitErr      Bad reference number
  14825.                     dRemoveErr      Tried to remove an open driver
  14826.                     unitEmptyErr    Bad reference number
  14827.  
  14828.  
  14829.     PBClose closes the device driver having the reference number
  14830. ioRefNum. Any pending I/O is completed, and the memory used by the
  14831. driver is released.
  14832. \ PBRead
  14833. 19
  14834. Function PBRead (paramBlock: ParmBlkPtr; async: BOOLEAN) : OSErr;
  14835.  
  14836.     Trap macro  _Read
  14837.  
  14838.     Parameter block
  14839.         --> 12  ioCompletion    pointer
  14840.         <-- 16  ioResult    word
  14841.         --> 24  ioRefNum    word
  14842.         --> 32  ioBuffer    pointer
  14843.         --> 36  ioReqCount  long word
  14844.         <-- 40  ioActCount  long word
  14845.         --> 44  ioPosMode   word
  14846.         <-> 46  ioPosOffset long word
  14847.  
  14848.  
  14849.  
  14850.  
  14851.     Result codes    noErr           No error
  14852.                     badUnitErr      Bad reference number
  14853.                     notOpenErr      Driver isn't open
  14854.                     unitEmptyErr    Bad reference number
  14855.                     readErr         Driver can't respond to Read
  14856.                                     calls
  14857.  
  14858.     PBRead attempts to read ioReqCount bytes from the device driver
  14859. having the reference number ioRefNum, and transfer them to the data
  14860. buffer pointed to by ioBuffer. After the read operation is completed,
  14861. the number of bytes actually read is returned in ioActCount.
  14862.  
  14863. Advanced programmers:  If the driver is reading from a block device,
  14864.                        the byte offset from the position indicated by
  14865.                        ioPosMode, where the read should actually betwin,
  14866.                        is given by ioPosOffset.
  14867. \ PBWrite
  14868. 19
  14869. Function PBWrite (paramBlock: ParmBlkPtr; async: BOOLEAN) : OSErr;
  14870.  
  14871.     Trap macro  _Write
  14872.  
  14873.     Parameter block
  14874.         --> 12  ioCompletion    pointer
  14875.         <-- 16  ioResult    word
  14876.         --> 24  ioRefNum    word
  14877.         --> 32  ioBuffer    pointer
  14878.         --> 36  ioReqCount  long word
  14879.         <-- 40  ioActCount  long word
  14880.         --> 44  ioPosMode   word
  14881.         --> 46  ioPosOffset long word
  14882.  
  14883.     Result codes    noErr       No error
  14884.             badUnitErr  Bad reference number
  14885.             notOpenErr  Driver isn't open
  14886.             unitEmptyErr    Bad reference number
  14887.             writErr Driver  can't respond to Write
  14888.                     calls
  14889.  
  14890.     PBWrite attempts to take ioReqCount bytes from the buffer pointed to
  14891. by ioBuffer and write them to the device driver having the reference
  14892. number ioRefNum. After the write operation is completed, the number of
  14893. bytes actually written is returned in ioActCount.
  14894.  
  14895. Advanced programmers:  If the driver is writing to a block device,
  14896.                        ioPosMode indicates whether the write should
  14897.                        begin relative to the beginning of the device or
  14898.                        the current position. The byte offset from the
  14899.                        position indicated by ioPosMode, where the write
  14900.                        should actually begin, is given by ioPosOffset.
  14901. \ PBControl
  14902. 19
  14903. Function PBControl (paramBlock: ParmBlkPtr; async: BOOLEAN) : OSErr;
  14904.  
  14905.     Trap macro  _Control
  14906.  
  14907.     Parameter block
  14908.         --> 12  ioCompletion    pointer
  14909.         <-- 16  ioResult    word
  14910.         --> 24  ioRefNum    word
  14911.         --> 26  csCode      word
  14912.         --> 28  csParam     record
  14913.  
  14914.     Result codes    noErr           No error
  14915.                     badUnitErr      Bad reference number
  14916.                     notOpenErr      Driver isn't open
  14917.                     unitEmptyErr    Bad reference number
  14918.                     controlErr      Driver can't respond to this
  14919.                                     Control call
  14920.  
  14921.  
  14922.     PBControl sends control information to the device driver having the
  14923. reference number ioRefNum. The type of information sent is specified
  14924. by csCode, and the information itself begins at csParam. The values
  14925. passed in csCode and csParam depend on the driver being called.
  14926. \ PBStatus
  14927. 19
  14928. Function PBStatus (paramBlock: ParmBlkPtr; async: BOOLEAN) : OSErr;
  14929.  
  14930.     Trap macro  _Status
  14931.  
  14932.     Parameter block
  14933.         --> 12  ioCompletion    pointer
  14934.         <-- 16  ioResult    word
  14935.         --> 24  ioRefNum    word
  14936.         --> 26  csCode      word
  14937.         --> 28  csParam     record
  14938.  
  14939.     Result codes    noErr       No error
  14940.             badUnitErr  Bad reference number
  14941.             notOpenErr  Driver isn't open
  14942.             unitEmptyErr    Bad reference number
  14943.             statusErr   Driver can't respond to this
  14944.                     Status call
  14945.  
  14946.     PBStatus returns status information about the device driver having
  14947. the reference number ioRefNum. The type of information returned is
  14948. specified by csCode, and the information itself begins at csParam. The
  14949. values passed in csCode and csParam depend on the driver being called.
  14950. \ PBKillIO
  14951. 19
  14952. Function PBKillIO (paramBlock: ParmBlkPtr; async: BOOLEAN) : OSErr;
  14953.  
  14954.     Trap macro  _KillIO
  14955.  
  14956.     Parameter block
  14957.         --> 12  ioCompletion    pointer
  14958.         <-- 16  ioResult    word
  14959.         --> 24  ioRefNum    word
  14960.  
  14961.     Result codes    noErr       No error
  14962.             badUnitErr  Bad reference number
  14963.             unitEmptyErr    Bad reference number
  14964.             controlErr  Driver can't respond to KillIO
  14965.                     calls
  14966.  
  14967.     KillIO stops any current I/O request being processed, and removes
  14968. all pending I/O requests from the I/O queue of the device driver having
  14969. the reference number ioRefNum. The completion routine of each pending
  14970. I/O request is called, with ioResult equal to the following result code:
  14971.  
  14972.     CONST abortErr = -27;
  14973.  
  14974. (note)
  14975.     KillIO is actually a special type of Control call, and
  14976.     all information about Control calls applies equally to
  14977.     KillIO.
  14978. \ DiskEject
  14979. 20
  14980. Function DiskEject (drvNum: INTEGER) : OSErr;
  14981.  
  14982.     __________________________________________________________________
  14983.  
  14984.     Assembly-language note: DiskEject is equivalent to a Control
  14985.     call with csCode equivalent to the global constant ejectCode.
  14986.     __________________________________________________________________
  14987.  
  14988.     DiskEject ejects the disk from the internal drive if drvNum is 1, or
  14989. from the external drive if drvNum is 2.
  14990.  
  14991.     Result codes
  14992.  
  14993.             noErr       No error
  14994.             nsDrvErr    No such drive
  14995. \ SetTagBuffer
  14996. 20
  14997. Function SetTagBuffer (buffPtr: Ptr) : OSErr;
  14998.  
  14999.     __________________________________________________________________
  15000.  
  15001.     Assembly-language note:  SetTagBuffer is equivalent to a Control
  15002.     call with csCode = 8.
  15003.     __________________________________________________________________
  15004.  
  15005.     An application can change the information used in the file tags
  15006. buffer by calling SetTagBuffer. The buffPtr parameter points to a
  15007. buffer that contains the information to be used. If buffPtr is NIL, the
  15008. information in the file tags buffer isn't changed.
  15009.  
  15010.     If buffPtr isn't NIL, every time the Disk Driver reads a sector from
  15011. the disk, it stores the file tags in the file tags buffer
  15012. by calling SetTagBuffer. The buffPtr parameter points to a buffer that
  15013. contains the information to be used. If buffPtr is NIL, the
  15014. information in the file tags buffer isn't changed.
  15015.  
  15016.     The contents of the buffer pointed to by buffPtr are overwritten at
  15017. the end of every read request (which can be composed of a number of
  15018. sectors) instead of at the end of every sector. Each read request
  15019. places 12 bytes in the buffer for each sector, always beginning at the
  15020. start of the buffer. This way an application can examine the file tags
  15021. for a number of sequentially read sectors. If a read request is
  15022. composed of a number of sectors, the Disk Driver reads 12 bytes from
  15023. the buffer for each sector. For example, for a read request of five
  15024. sectors, the Disk Driver will read 60 bytes from the buffer.
  15025.  
  15026.     __________________________________________________________________
  15027.  
  15028.     Assembly-language note:  An assembly-language program can change
  15029.     the information used in the file tags buffer by storing a
  15030.     pointer to the buffer containing the information in the global
  15031.     variable TagBufPtr. If TagBufPtr is 0, the information in the
  15032.     file tags buffer isn't changed.
  15033.     __________________________________________________________________
  15034.  
  15035.     Result codes
  15036.  
  15037.             noErr       No error
  15038. \ DriveStatus
  15039. 20
  15040. Function DriveStatus (drvNum: INTEGER; VAR status: DrvSts) : OSErr;
  15041.  
  15042.     _________________________________________________________________
  15043.  
  15044.     Assembly-language note:  DriveStatus is equivalent to a Status
  15045.     call with csCode equivalent to teh globval constant drvStsCode.
  15046.     _________________________________________________________________
  15047.  
  15048.     DriveStatus returns information about the internal drive if drvNum
  15049. is 1, or about the external drive if drvNum is 2. The information is
  15050. returned in a record of type DrvSts:
  15051.  
  15052. TYPE DrvSts = RECORD
  15053.         track:      INTEGER;     {current track}
  15054.         writeProt:  SignedByte;  {bit 7=1 if volume is locked}
  15055.         diskInPlace:    SignedByte;  {disk in place}
  15056.         installed:  SignedByte;  {drive installed}
  15057.         sides:      SignedByte;  {bit 7=0 if single-sided drive}
  15058.         qLink:      QElmPtr;     {next queue entry}
  15059.         qType:      INTEGER;     {not used}
  15060.         dqDrive:    INTEGER;     {drive number}
  15061.         dqRefNum:   INTEGER;     {driver reference number}
  15062.         dqFSID:     INTEGER;     {file-system identifier}
  15063.         twoSideFmt: SignedByte;  {-1 if two-sided disk}
  15064.         needsFlush: SignedByte;  {reserved}
  15065.         diskErr:    INTEGER;     {error count}
  15066.       END;
  15067.  
  15068.     The diskInPlace field is 0 if there's no disk in the drive, 1 or 2
  15069. if there is a disk in the drive, or -4 to -1 if the disk was ejected in
  15070. the last 1.5 seconds. The installed field is 1 if the drive might be
  15071. connected to the Macintosh, and -1 if the drive isn't installed.
  15072. The value oftwoSideFmt is valid only when diskInPlace = 2. The value
  15073. of diskErrs is incremented every time an error occurs internally within
  15074. the Disk Driver.
  15075.  
  15076.     Result codes
  15077.  
  15078.             noErr       No error
  15079.             nsDrvErr    No such drive
  15080. \ RAMSDOpen
  15081. 22
  15082. Function RAMSDOpen (whichPort: SPortSel; rsrcType: OSType; rsrcID:
  15083.         INTEGER) : OSErr;
  15084.  
  15085.     RAMSDOpen closes the ROM Serial Driver and opens the RAM input and
  15086. output drivers for the port identified by the whichPort parameter,
  15087. which must be a member of the SPortSel set:
  15088.  
  15089.     TYPE SPortSel = (sPortA, {modem port}
  15090.              sPortB  {printer port});
  15091.  
  15092.     RsrcType and rsrcID indicate the resource type and resource ID of
  15093. the RAM Serial Driver, which should be stored in your application's
  15094. resource file. (OSType is an Operating System Utility data type
  15095. declared the same as ResType in the Resource Manager.)
  15096.  
  15097.     Result codes
  15098.  
  15099.             noErr       No error
  15100.             openErr     Can't open driver
  15101. \ RAMSDClose
  15102. 22
  15103. Procedure RAMSDClose (whichPort: SPortSel);
  15104.  
  15105.     RAMSDClose closes the RAM input and output drivers for the port
  15106. identified by the whichPort parameter, which must be a member of the
  15107. SPortSel set (defined int eh description of RAMSDOpen above).
  15108. \ SerReset
  15109. 22
  15110. Function SerReset (refNum: INTEGER; serConfig: INTEGER) : OSErr;
  15111.  
  15112.     SerReset resets and reinitializeds the input or output driver having
  15113. the reference number refNum according to the information in serConfig.
  15114. Figure 3 shows the format of serConfig.
  15115.  
  15116.     You can use the following predefined constants to set the values of
  15117. various bits of serConfig:
  15118.  
  15119. CONST   baud300     = 380;      {300 baud}
  15120.         baud600     = 189;      {600 baud}
  15121.         baud1200    = 94;       {1200 baud}
  15122.         baud1800    = 62;       {1800 baud}
  15123.         baud2400    = 46;       {2400 baud}
  15124.         baud3600    = 30;       {3600 baud}
  15125.         baud4800    = 22;       {4800 baud}
  15126.         baud7200    = 14;       {7200 baud}
  15127.         baud9600    = 10;       {9600 baud}
  15128.         baud19200   = 4;        {19200 baud}
  15129.         baud57600   = 0;        {57600 baud}
  15130.         stop10      = 16384;    {1 stop bit}
  15131.         stop15      = -32768;   {1.5 stop bits}
  15132.         stop20      = -16384;   {2 stop bits}
  15133.         noParity    = 8192;     {no parity}
  15134.         oddParity   = 4096;     {odd parity}
  15135.         evenParity  = 12288;    {even parity}
  15136.         data5       = 0;        {5 data bits}
  15137.         data6       = 2048;     {6 data bits}
  15138.         data7       = 1024;     {7 data bits}
  15139.         data8       = 3072;     {8 data bits}
  15140.  
  15141.  
  15142.     For example, the default setting of 9600 baud, eight data bits, two
  15143. stop bits, and no parity bit is equivalent to baud9600+data8+stop20+
  15144. noParity.
  15145. \ SerSetBuf
  15146. 22
  15147. Function SerSetBuf (refNum: INTEGER; serBPtr: Ptr; serBLen: INTEGER) :
  15148.         OSErr;
  15149.  
  15150.     SerSetBuf specifies a new input buffer for the input driver having
  15151. the reference number refNum. SerBPtr points to the buffer, and serBLen
  15152. specifies the number of bytes in the buffer. If serBLen is 0, a
  15153. 64-byte default buffer provided by the driver is used.
  15154.  
  15155. (warning)
  15156.     You must lock this buffer while it's in use.
  15157.  
  15158.     __________________________________________________________________
  15159.  
  15160.     Assembly-language note: SerSetBuf is equivalent to a Control
  15161.     call with csCode=9, csParam=serBPtr, and csParam+2=serBLen.
  15162.     __________________________________________________________________
  15163.  
  15164.     Result codes    noErr       No error
  15165. \ SerHShake
  15166. 22
  15167. Function SerHShake (refNum: INTEGER; flags: SerShk) : OSErr;
  15168.  
  15169.     SerHShake sets handshake options and other control information, as
  15170. specified by the flags parameter, for the input or output driver having
  15171. the reference number refNum. The flags parameter has the following
  15172. data structure:
  15173.  
  15174.     TYPE SerShk = PACKED RECORD
  15175.             fXOn: Byte; {XOn/XOff output flow control flag}
  15176.             fCTS: Byte;     {CTS hardware handshake flag}
  15177.             xOn:  CHAR; {XOn character}
  15178.             xOff: CHAR; {XOff character}
  15179.             errs: Byte; {errors that cause abort}
  15180.             evts: Byte; {status changes that cause events}
  15181.             fInX: Byte; {XOn/XOff input flow control flag}
  15182.             null: Byte  {not used}
  15183.                END;
  15184.  
  15185.     If fXOn is nonzero, XOn/XOff output flow control is enabled; if fInX
  15186. is nonzero, XOn/XOff input flow control is enabled. XOn and xOff specify
  15187. the XOn character and XOff character used for XOn/XOff flow control.
  15188. If fCTS is nonzero, CTS hardware handshake is enabled. The errs field
  15189. indicates which errors will cause input requests to be aborted; for
  15190. each type of error, there's  a predefined constant in which the
  15191. corresponding bit is set:
  15192.  
  15193.     CONST parityErr     = 16;   {set for parity error}
  15194.           hwOverrunErr  = 32;   {set for hardware overrun error}
  15195.           framingErr    = 64;   {set for framing error}
  15196.  
  15197. (note)
  15198.     The ROM Serial Driver doesn't support XOn/XOff input flow
  15199.     control or aborts caused by error conditions.
  15200.  
  15201.     The evts field indicates whether changes in the CTS or break status
  15202. will cause the Serial Driver to post device driver events; you can use
  15203. the following predefined constants to set or test the value of evts:
  15204.  
  15205.     CONST ctsEvent   = 32;  {set if CTS change will cause event to}
  15206.                 {be posted}
  15207.           breakEvent = 128; {set if break status change will cause}
  15208.                     {event to be posted}
  15209.  
  15210.  
  15211. (warning)
  15212.     Use of this option is discouraged because of the long
  15213.     time that interrupts are disabled while such an event is
  15214.     posted.
  15215.  
  15216.     ___________________________________________________________________
  15217.  
  15218.     Assembly-language note:  SerHShake is equivalent to a Control
  15219.     call with csCode=10 and csParam through csParam+6 equivalent to
  15220.     the fields of a variable of type SerShk.
  15221.     ___________________________________________________________________
  15222.  
  15223.     Result codes    noErr       No error
  15224. \ SerSetBrk
  15225. 22
  15226. Function SerSetBrk (refNum: INTEGER) : OSErr;
  15227.  
  15228. SerSetBrk sets break mode in the input or output driver having the
  15229. reference number refNum.
  15230.  
  15231.     ___________________________________________________________________
  15232.  
  15233.     Assembly-language note:  SerSetBrk is equivalent to a Control
  15234.     call with csCode=12.
  15235.     ___________________________________________________________________
  15236.  
  15237.     Result codes
  15238.  
  15239.             noErr       No error
  15240. \ SerClrBrk
  15241. 22
  15242. Function SerClrBrk (refNumk: INTEGER) : OSErr;
  15243.  
  15244.     SerClrBrk clears break mode in the inplut or output driver having
  15245. the reference number refNum.
  15246.  
  15247.     __________________________________________________________________
  15248.  
  15249.     Assembly-language note:  SerClrBrk is equivalent to a Control
  15250.     call with csCode=11.
  15251.     __________________________________________________________________
  15252.  
  15253.     Result codes
  15254.  
  15255.         noErr       No error
  15256. \ SerGetBuf
  15257. 22
  15258. Function SerGetBuf (refNum: INTEGER; VAR count: LONGILNT) ; OSErr;
  15259.  
  15260.     SerGetBuf returns, in the count parameter, the number of bytes in
  15261. the buffer of the input driver having the reference number refNum.
  15262.  
  15263.     ____________________________________________________________________
  15264.  
  15265.     Assembly-language note:  SerGetBuf is equivalent to a Status
  15266.     call with csCode=2. The number of bytes in the buffer is
  15267.     returned in csParam.
  15268.     ____________________________________________________________________
  15269.  
  15270.     Result codes
  15271.  
  15272.         noErr       No error
  15273. \ SerErrFlag
  15274. 22
  15275. Function SerErrFlag (refNum: INTEGER; VAR serSta: SerStaRec) : OSErr;
  15276.  
  15277.     SerErrFlag returns in serSta three words of status information for
  15278. the input or output driver having the reference number refNum. The
  15279. serSta parameter has the following data structure:
  15280.  
  15281.     TYPE SerStaRec = PACKED RECORD
  15282.                cumErrs:   Byte; {cumulative errors}
  15283.                xOffSent:  Byte; {XOff sent as input flow}
  15284.                         { control}
  15285.                rdPend:    Byte; {read pending flag}
  15286.                wrPend:    Byte;     {write pending flag}
  15287.                ctsHold:   Byte; {CTS flow control hold flag}
  15288.                xOffHold:  Byte; {XOff received as output}
  15289.                             { flow control}
  15290.              END;
  15291.  
  15292.     CumErrs indicates which errors have occurred since the last time
  15293. SerErrFlag was called:
  15294.  
  15295.        CONST swOverrunErr = 1;  {set for software overrun error}
  15296.          parityErr    = 16; {set for parity error}
  15297.          hwOverrunErr = 32; {set for hardware overrun error}
  15298.          framingErr   = 64; {set for framing error}
  15299.  
  15300.  
  15301.     If the driver has sent an XOff character, xOffSent will be equal to
  15302. the following predefined constant:
  15303.  
  15304.     CONST xOffWasSent = $80;    {XOff character was sent}
  15305.  
  15306.     If the driver has a Read or Write call pending, rdPend or wrPend,
  15307. respectively, will be nonzero. If output has been suspended because
  15308. the hardware handshake was negated, ctsHold will be nonzero. If output
  15309. has been suspended because an XOff character was received, xOffHold
  15310. will be nonzero.
  15311.  
  15312.     __________________________________________________________________
  15313.  
  15314.     Assembly-language note:  SerStatus is equivalent to a Status
  15315.     call with csCode=8. The status information is returned in
  15316.     csParam through csParam+5.
  15317.     __________________________________________________________________
  15318.  
  15319.     Result codes    noErr       No error
  15320. \ MPPOpen
  15321. 23
  15322. Function MPPOpen : OSErr;
  15323.  
  15324. MPPOpen first checks whether the .MPP driver is already loaded; if it
  15325. is, MPPOpen does nothing and returns noErr. If MPP hasn't been loaded,
  15326. MPPOpen attempts to load it into the system heap. If it succeeds, it
  15327. then initializes the driver's variables and goes through the process of
  15328. dynamically assigning a node ID to that Macintosh. On a Macintosh 512K
  15329. or XL, it also loads the .ATP driver and NBP code into the system heap.
  15330.  
  15331. If serial port B isn't configured for AppleTalk, or is already in use,
  15332. the .MPP driver isn't loaded and an appropriate result code is
  15333. returned.
  15334.  
  15335.     Result codes
  15336.  
  15337.             noErr       No error
  15338.             portInUse   Port B is already in use
  15339.             portNotCf   Port B not configured for AppleTalk
  15340. \ MPPClose
  15341. 23
  15342. Function MPPClose : OSErr;
  15343.  
  15344. MPPClose removes the .MPP driver, and any data structures associated
  15345. with it, from memory. If the .ATP driver or NBP code were also
  15346. installed, they'll also be removed. MPPClose also returns the use of
  15347. port B to the Serial Driver.
  15348.  
  15349. (warning)
  15350.     Since other co-resident programs may be using AppleTalk,
  15351.     it's strongly recommended that you never use this call.
  15352.     MPPClose will completely disabale AppleTalk; the only way
  15353.     to restore ApleTalk is to call MPPOpen again.
  15354. \ LAPOpenProtocol
  15355. 23
  15356. Function LAPOpenProtocol (theLAPType: ABBYte; protoPtr: Ptr) : OSErr;
  15357.  
  15358.  
  15359.      LAPOpenProtocol adds the LAP protocol type specified by theLAPType to the node's protocol table. If you provide a pointer to a protocol
  15360. handler in protoPtr, ALAP will send each frame with a LAP protocol type
  15361. of theLAPType to that protocol handler.
  15362.  
  15363.      If protoPtr is NIL, the default protocol handler will be used for
  15364. receiving frames with a LAP protocol type of theLAPType. In this case,
  15365. to receive a frame you must acall LAPRead to provide the default
  15366. protocol handler with a buffer for placing the data. If, however,
  15367. you've written your own protocol handler and protoPtr points to it,
  15368. your protocol handler will have the responsibility fro receiving the
  15369. frame and it's not necessary to call LAPRead.
  15370.  
  15371.     Result codes
  15372.  
  15373.             noErr       No error
  15374.             lapProtErr  Error attaching protocol type
  15375. \ LAPWrite
  15376. 23
  15377. Function LAPWrite (abRecord: ABRecHandle; async: BOOLEAN) : OSErr;
  15378.  
  15379.  
  15380.     ABusRecord
  15381.     ----------
  15382.        <--    abOpcode          {always tLAPWrite}
  15383.        <--    abResult          {result code}
  15384.        -->    abUserReference       {for your use}
  15385.        -->    lapAddress.dstNodeID      {destination node ID}
  15386.        -->    lapAddress.lapProtType    {LAP protocol type}
  15387.        -->    lapReqCount           {length of frame data}
  15388.        -->    lapDataPtr            {pointer to frame data}
  15389.  
  15390. LAPWrite sends a frame to another node. LAPReqCount and lapDataPtr
  15391. specify the length and location of the data to send. The
  15392. lapAddress.lapProtType field indicates the node ID of the node to
  15393. which the frame should be sent.
  15394.  
  15395. (note)
  15396.     The first two bytes of an ALAP frame's data must contain
  15397.     the length in bytes of the data, including the length
  15398.     bytes themselves.
  15399.  
  15400.     Result codes
  15401.  
  15402.             noErr           No error
  15403.             excessCollsns   Unable to contact destination
  15404.                             node; packet not sent
  15405. \ LAPRead
  15406. 23
  15407. Function LAPRead (abRecord: ABRecHandle; async: BOOLEAN) : OSErr;
  15408.  
  15409.  
  15410.     ABusRecord
  15411.     ----------
  15412.        <--    abOpcode              {always tLAPWrite}
  15413.        <--    abResult              {result code}
  15414.        -->    abUserReference       {for your use}
  15415.        <--    lapAddress.dstNodeID  {packet's destination node ID}
  15416.        <--    lapAddress.srcNodeID  {packet's source node ID}
  15417.        -->    lapAddress.lapProtType{LAP protocol type}
  15418.        -->    lapReqCount           {buffer size in bytes}
  15419.        <--    lapActCount           {number of frame data bytes actually
  15420.                                      received}
  15421.        -->    lapDataPtr            {pointer to buffer}
  15422.  
  15423.  
  15424.        LAPRead receives a frame from another node. LAPReqCount and
  15425. lapDataPtr specify the length and location of the buffer that will receive the frame data. If the buffer isn't large enough to hold all of the incoming frame data, the extra bytes wil be discarded and buf2SmallErr will be returned. The number of bytes actually received is returned in lapActCount. Only frames with LAP protocol type equal to
  15426. lapAddress.lapProtType will be received. The node number of the
  15427. frame's source and destination nodes are returned in
  15428. lapAddress.srcNodeID and lapAddress.dstNodeID respectively. You can
  15429. determine if the packet was broadcast to you by examining the value of
  15430. lapAddress.dstNodeID--if the packet was broadcast it's equal to 255,
  15431. otherwise it's equal to your node ID.
  15432.  
  15433. (note)
  15434.     You should issue LAPRead calls only for LAP protocol
  15435.     types that were opened (via LAPOpenProtocol) to use the
  15436.     default protocol handler.
  15437.  
  15438.     Result codes
  15439.  
  15440.             noErr           No error
  15441.             buf2SmallErr    Frame too large for buffer
  15442.             readQErr        Invalid protocol type or
  15443.                             protocol type not found in table
  15444. \ LAPRdCancel
  15445. 23
  15446. Function LAPRdCancel (abRecord: ABRecHandle) : OSErr;
  15447.  
  15448.     Given the handle to the ABusRecord of a previously made LAPRead call,
  15449. LAPRdCancel dequeues the LAPRead call, provided that a packet
  15450. satisfying the LAPRead has not already arrived. LAPRdCancel returns
  15451. noErr if the LAPRead call is successfully removed fdrom the queue. If
  15452. LAPRdCancel returns recNotFnd, check the abResult field to verify that
  15453. the LAPRead has been completed and determine its outcome.
  15454.  
  15455.     Result codes
  15456.  
  15457.             noErr       No error
  15458.             readQErr    Invalid protocol type or
  15459.                         protocol type not found in table
  15460.             recNotFnd   ABRecord n ot found in queue
  15461. \ DDPOpenSocket
  15462. 23
  15463. Function DDPOpenSocket (VAR theSocket: Byte; sktListener: Ptr) : OSErr;
  15464.  
  15465.  
  15466.        DDPOpenSocket adds a socket and its socket listener to the socket table. If theSocket is nonzero (it must be in the range of 64 to 127),
  15467. it specifies the socket's number. If theSocket is 0, DDPOpenSocket dynamically assigns a socket number in the range 128 to 254, and
  15468. returns it in theSocket. SktListener contains a pointer to the socket listener; if it's NIL, the default listener will be used.
  15469.  
  15470.        If you're using the default socket listener, you must then call DDPRead to receive a datagram (in order to specify buffer space for the default socket listener). If, however, you've written your own socket listener and sktListener points to it, your listener will provide buffers for receiving datagrams and you shouldn't use DDPRead calls.
  15471.  
  15472.        DDPOpenSocket will return ddpSktErr if you pass the number of an already opened socket, if you pass a socket number greater than 127, or
  15473. if the socket table is full.
  15474.  
  15475. (note)
  15476.     The range of static socket numbers 1 through 63 is
  15477.     reserved for use by AppleTalk. Socket numbers 64 through
  15478.     127 are available for unrestricted experimental use.
  15479.  
  15480.     Result codes
  15481.  
  15482.             noErr       No error
  15483.             ddpSktErr   Socket error
  15484. \ DDPCloseSocket
  15485. 23
  15486. Function DDPCloseSocket (theSocket: Byte) : OSErr;
  15487.  
  15488.        DDPCloseSocket removes the entry of the specified socket from the
  15489. socket table and cancels all pending DDPRead calls that have been made
  15490. to close a socket that isn't open, DDPCloseSocket will return
  15491. ddpSktErr.
  15492.  
  15493.     Result codes
  15494.  
  15495.             noErr       No error
  15496.             ddpSktErr   Socket error
  15497. \ DDPWrite
  15498. 23
  15499. Function DDPWrite (abRecord: ABRecfHandle; doChecksum: BOOLEAN; async:
  15500.                     BOOLEAN) : OSErr;
  15501.  
  15502.     ABusRecord
  15503.     ----------
  15504.        <--    abOpcode          {always tDDPWrite}
  15505.        <--    abResult          {result code}
  15506.        -->    abUserReference   {for your use}
  15507.        -->    ddpType           {DDP protocol type}
  15508.        -->    ddpSocket         {source socket number}
  15509.        -->    ddpAddress        {destination socket address}
  15510.        -->    ddpReqCount       {length of datagram data}
  15511.        -->    ddpDataPtr        {pointer to buffer}
  15512.  
  15513.        DDPWrite sends a datagram to another socket. DDPReqCount and
  15514. ddpDataPtr specify the length and location of the data to send. The
  15515. ddpType field indicates the DDP protocol type of the frame, and
  15516. ddpAddress is the complete internet address of the socket to which the
  15517. datagram should be sent. DDPSocket specifies the socket from which the
  15518. datagram should be sent. Datagrams sent over the internet to a node on
  15519. an AppleTalk network different from the sending node's network have an
  15520. optional software checksum to detect errors that might occur inside the
  15521. intermediate bridges. If doChecksum is TRUE, DDPWrite will compute
  15522. this checksum; if it's FALSE, this software checksum feature is
  15523. ignored.
  15524.  
  15525. (note)
  15526.     The destination socket can't be in the same node as the
  15527.     program making the DDPWrite call.
  15528.  
  15529.     Result codes
  15530.  
  15531.             noErr       No error
  15532.             ddpLenErr   Datagram length too big
  15533.             ddpSktErr   Source socket not open
  15534. \ DDPRead
  15535. 23
  15536. Function DPRead (abRecord: ABRecfHandle; retChecksum: BOOLEAN; async:
  15537.                   BOOLEAN) : OSErr;
  15538.  
  15539.     ABusRecord
  15540.     ----------
  15541.        <--    abOpcode          {always tDDPWrite}
  15542.        <--    abResult          {result code}
  15543.        -->    abUserReference   {for your use}
  15544.        <--    ddpType           {DDP protocol type}
  15545.        -->    ddpSocket         {listening socket number}
  15546.        <--    ddpAddress        {source socket address}
  15547.        -->    ddpReqCount       {buffer size in bytes}
  15548.        <--    ddpActCount       {number of bytes actually received}
  15549.        -->    ddpDataPtr        {pointer to buffer}
  15550.        <--    ddpNodeID         {original destination node ID}
  15551.  
  15552.  
  15553.        DDPRead receives a datagram from another socket. The length and
  15554. location of the buffer that will receive the data are specified by
  15555. ddpReqCount and ddpDataPtr, respectively. If the buffer isn't large
  15556. enough to hold all of the incoming frame data, the extra bytes will be
  15557. discarded and buf2SmallErr will be returned. The numbr of bytes
  15558. actually received is returned in ddpActCount. DDPSocket specifies the
  15559. socket to receive the datagram (the "listening" socket). The node to
  15560. which the packet was sent is returned in ddpNodeID; if the packet was
  15561. broadcast ddpNodeID will contain 255. The address of the socket that
  15562. sent the packet is returned in ddpAddress. If retCksumErrs is FALSE,
  15563. DDPRead will discard any packets received with an invalid checksum and
  15564. inform the caller of the error. If retCksumErr is TRUE, DDPRead will
  15565. deliver all packets, regardless of whether the checksum is valid or
  15566. not; it will also notify the caller when there's a checksum error.
  15567.  
  15568. (note)
  15569.     The sender of the datagram must be in a different node
  15570.     from the receiver. Youk should issue DDPRead calls only
  15571.     for receiving datagrams for sockets opened with the
  15572.     default socket listener; see the description of
  15573.     DDPOpenSocket.
  15574.  
  15575. (note)
  15576.     If DDPRead returns buf2SmallErr, it will deliver packets
  15577.     even if retCksukmErrs is FALSE.
  15578.  
  15579.     Result codes
  15580.  
  15581.             noErr         No error
  15582.             buf2SmallErr  Datagram too large for buffer
  15583.             cksumErr      Checksum error
  15584.             ddpLenErr     Datagram length too big
  15585.             ddpSktErr     Socket error
  15586.             readQErr      Invalid socket or
  15587.                           socket not found in table
  15588. \ DDPRdCancel
  15589. 23
  15590. Function DDPRdCancel (abRecord: ABRecHandle) : OSErr;
  15591.  
  15592.        Given the handle to the ABusRecord of a previously made DDPRead
  15593. call, DDPRdCancel dequeues the DDPRead call, provided that a packet
  15594. satisfying the DDPRead hasn't already arrived. DDPRdCancel returns
  15595. noErr if the DDPRead call is successfully removed from the queue. If
  15596. DDPRdCancel returns recNotFnd, check the abResult field of abRecord to
  15597. verify that the DDPRead has been completed and determine its outcome.
  15598.  
  15599.  
  15600.     Result codes
  15601.  
  15602.        noErr       No error
  15603.        readQErr    Invalid socket or socket not found in table
  15604.        recNotFnd   ABRecord not found in queue
  15605. \ ATPLoad
  15606. 23
  15607. Function ATPLoad : OSErr;
  15608.  
  15609.        ATPLoad first verifies that the .MPP driver is loaded and running.
  15610. If it isn't, ATPLoad verifies that port B is configured for AppleTalk, and is not in use, and then loads MPP into the system heap.
  15611.  
  15612.        ATPLoad then loads the .ATP driver, unless it's already in memory.
  15613. On a Macintosh 128K, ATPLoad reads the .ATP driver from the system
  15614. resource file into the application heap; on a Macintosh 512K or XL, ATP
  15615. is read into the system heap.
  15616.  
  15617. (note)
  15618.     On a Macintosh 512K or XL, ATPLoad and MPPOpen perform
  15619.     essentially the same function.
  15620.  
  15621.  
  15622.  
  15623.     Result codes
  15624.  
  15625.             noErr       No error
  15626.             portInUse   Port B is already in use
  15627.             portNotCf   Port B not configured for AppleTalk
  15628. \ ATPUnload
  15629. 23
  15630. Function ATPUnload : OSErr;
  15631.  
  15632.        ATPUnload makes the .ATP driver purgeable; the space isn't actually released by the Memory Manager until necessary.
  15633.  
  15634. (note)
  15635.     This call applies only to a Macintosh 128K; on a
  15636.     Macintosh 512K or Macintosh XL, ATPUnload has no effect.
  15637.  
  15638.     Result codes
  15639.  
  15640.            noErr       No error
  15641. \ ATPOpenSocket
  15642. 23
  15643. Function ATPOpenSocket (addrRcvd: AddrBlock; VAR atpSocket: Byte) :
  15644.                           OSErr;
  15645.  
  15646.        ATPOpenSocket opens a socket for the purpose of receiving requests. ATPSocket contains the socket number of the socket to open; if it's 0, a number is dynamically assigned and returned in atpSocket. AddrRcvd contains a filter of the sockets from which requests will be accepted. A 0 in the network number, node ID, or socket number field of the addrRcvd record acts as a "wild card"; for instance, a 0 in the socket number field means that requests will be accepted from all sockets in the node(s) specified by the network and node fields.
  15647.  
  15648.     Result codes
  15649.  
  15650.             noErr       No error
  15651.             tooManySkts Socket table ful
  15652.             noDataArea  Too many outstanding ATP calls
  15653.  
  15654. (note)
  15655.     If you're only going to send requests and receive
  15656.     responses to these requests, you don't need to open an
  15657.     ATP socket. When you make the ATPSndRequest or
  15658.     ATPRequest call, ATP automatically opens a dynamically
  15659.     assigned socket for that purpose.
  15660. \ ATPCloseSocket
  15661. 23
  15662. Function ATPCLoseSocket (atpSocket: Byte) : OSErr;
  15663.  
  15664.        ATPCloseSocket closes the responding socket whose number is specified by atpSocket. It releases the data structures associated with all pending, asynchronous calls involving that socket; these pending calls are completed immediately and return the result code sktClosed.
  15665.  
  15666.     Result codes
  15667.  
  15668.             noErr       No error
  15669.             noDataArea  Too many outstanding ATP calls
  15670. \ ATPSndRequest
  15671. 23
  15672. Function ATPSndRequest (abRecord: ABRecHandle; async: BOOLEAN) : OSErr;
  15673.  
  15674.  
  15675.     ABusRecord
  15676.     ----------
  15677.        <--  abOpcode        {always tATPSndRequest}
  15678.        <--  abResult        {result code}
  15679.        -->  abUserReference {for your use}
  15680.        -->  atpAddress      {destination socket address}
  15681.        -->  atpReqCount     {request size in bytes}
  15682.        -->  atpDataPtr      {pointer to buffer}
  15683.        -->  atpRspBDSPtr    {pointer to response BDS}
  15684.        -->  atpUserData     {user bytes}
  15685.        -->  atpXO           {exactly-once flag}
  15686.        <--  atpEOM          {end-of-message flag}
  15687.        -->  atpTimeOut      {retry timeout interval in seconds}
  15688.        -->  atpRetries      {maximum number of retries}
  15689.        -->  atpNumBufs      {number of elements in response BDS}
  15690.        <--  atpNumRsp       {number of response packets actually }
  15691.                             {received}
  15692.  
  15693.        ATPSndRequest sends a request to another socket. ATPAddress is the internet address of the socket to which the request should be sent. ATPDataPtr and atpReqCount specify the location and size of a buffer that contains the request information to be sent. ATPUserData contains the user bytes for the ATP header.
  15694.  
  15695.        ATPSndRequest requires you to allocate a response BDS. ATPRspBDSPtr is a pointer to the response BDS; atpNumBufs indicates the number of BDS elements in the BDS (this is also the maximum number of response datagrams that will be accepted). The number of response datagrams actually received is returned in atpNumRsp; if a nonzero value is returned, you can examine the response BDS to determine which packet of the transaction were actually received. If the number returned is less than requested, one of the folowing is true:
  15696.  
  15697.     - Some of the packets have been lost and the retry count has been
  15698.       exceeded.
  15699.  
  15700.     - ATPEOM is TRUE; this means that the response consisted of fewer
  15701.       packets than were expected, but that all packets sent were
  15702.       received (the last packet came with the atpEOM flag set).
  15703.  
  15704.        ATPTimeOut indicates the length of time that ATPSndRequest should wait for a response before retransmitting the request. ATPRetries indicates the maximum number of retries ATPSndRequest shoud attempt. ATPXO should be TRUE if you want the request to be part of an exactly-once transaction.
  15705.  
  15706.        ATPSndRequest completes when either the transaction is completed or the retry count is exceeded.
  15707.  
  15708.     Result codes
  15709.  
  15710.             noErr       No error
  15711.             reqFailed   Retry count exceeded
  15712.             tooManyReqs Too many concurrent requests
  15713.             noDataArea  Too many outstanding ATP calls
  15714. \ ATPRequest
  15715. 23
  15716. Function ATPRequest (abRecord: ABRecHandle; async: BOOLEAN) : OSErr;
  15717.  
  15718.  
  15719.     ABusRecord
  15720.     ----------
  15721.        <--  abOpcode        {always tATPRequest}
  15722.        <--  abResult        {result code}
  15723.        -->  abUserReference {for your use}
  15724.        -->  atpAddress      {destination socket address}
  15725.        -->  atpReqCount     {request size in bytes}
  15726.        -->  atpDataPtr      {pointer to buffer}
  15727.        <--  atpActCount     {number of bytes actually received}
  15728.        -->  atpUserData     {user bytes}
  15729.        -->  atpXO           {exactly-once flag}
  15730.        <--  atpEOM          {end-of-message flag}
  15731.        -->  atpTimeOut      {retry timeout interval in seconds}
  15732.        -->  atpRetries      {maximum number of retries}
  15733.        <--  atpRspUData     {user bytes received in transaction response
  15734.        -->  atpRspBuf       {pointer to response message buffer}
  15735.        -->  atpRspSize      {size of response message buffer}
  15736.  
  15737.        ATPRequest is functionally analogous to ATPSndRequest. It sends a
  15738. request to another socket, but doesn't require the caller to set up and
  15739. use the BDS data structure to describe the response buffers.
  15740. ATPAddress indicates the socket to which the request should be sent.
  15741. ATPDataPtr and atpReqCount specify the location and size of a buffer
  15742. that contains the request information to be sent. ATPUserData contains
  15743. the uset bytes to be sent in the request's ATP header. ATPTimeOut
  15744. indicates the length of time that ATPRequest should wait for a response
  15745. before retransmitting the request. ATPRetries indicates the maximum
  15746. number of retries ATPRequest should attempt.
  15747.  
  15748.        To use this call, you must have an area of contiguous buffer space that's large enough to receive all expected datagrams. The various
  15749. datagrams will be assembled in this buffer and returned to you as a complete message upon completion of the transaction. The address and size of this buffer are pased in atpRspBuf and atpRspSize, respectively. Upon completion of the call, the size ofthe received response message is returned in atpActCount. The user bytes received in the ATP header of the first response packet are returned in atpRspUData. ATPXO should be TRUE if you want the request to be part of an exactly-once transaction.
  15750.  
  15751.        Although you don't provide a BDS, ATPRequest in fact creates one and calls the .ATP driver (as in an ATPSndRequest call). For this reason, the abRecord fields atpRspBDSPtr and atpNumBufs are used by ATPRequest; you should not expect these fields to remain unaltered during or after the function's execution.
  15752.  
  15753.        For ATPRequest to receive and correctly deliver the response as a single message, the responding end must, upon receiving the request (with an ATPGetRequest call), generate the complete response as a complete message in a single buffer and then call ATPResponse.
  15754.  
  15755. (note)
  15756.     The responding end could also use ATPSndRsp and ATPAddRsp
  15757.     provided that each response packet (except the last one)
  15758.     contains exactly 578 ATP data bytes; the last packet in
  15759.     the response can contain less than 578 ATP data bytes.
  15760.     Also, if this method is used, only the ATP user bytes of
  15761.     the first response packet will be delivered to the
  15762.     requester; any information in the user bytes of the
  15763.     remaining response packets will not be delivered.
  15764.  
  15765.        ATPRequest completes when either the transaction is completed or
  15766. the retry count is exceeded.
  15767.  
  15768.     Result code
  15769.  
  15770.             noErr       No error
  15771.             reqFailed   Retry count exceeded
  15772.             tooManyReqs Too many concurrent requests
  15773.             sktClosed   Socket closed by a cancel call
  15774.             noDataArea  Too many outstanding ATP calls
  15775. \ ATPReqCancel
  15776. 23
  15777. Function ATPReqCancel (abRecord: ABRecHandle; async: BOOLEAN) : OSErr;
  15778.  
  15779.  
  15780.        Given the handle to the ABusRecord of a previously made ATPSndRequest or ATPRequest call, ATPReqCancel dequeues the ATPSndRequest
  15781. or ATPRequest call, provided that the call hasn't already completed. ATPReqCancel returns noErr if the ATPSndRequest or ATPRequest call is
  15782. successfully removed from the queue. If it returns cbNotFound, check the abResult field of abRecord to verify that the ATPSndRequest or
  15783. ATPRequest call has been completed and determine its outcome.
  15784.  
  15785.     Result codes
  15786.  
  15787.             noErr       No error
  15788.             cbNotFound  ATP control block not found
  15789. \ ATPGetRequest
  15790. 23
  15791. Function ATPGetRequest (abRecord: ABRecHandle; async: BOOLEAN) :
  15792.                          OSErr;
  15793.  
  15794.     ABusRecord
  15795.     ----------
  15796.        <--  abOpcode        {always tATPGetRequest}
  15797.        <--  abResult        {result code}
  15798.        -->  abUserReference {for your use}
  15799.        -->  atpSocket       {listening socket number}
  15800.        <--  atpAddress      {source socket address}
  15801.        -->  atpReqCount     {buffer size in bytes}
  15802.        -->  atpDataPtr      {pointer to buffer}
  15803.        <--  atpBitMap       {transaction bit map}
  15804.        <--  atpTransID      {transaction ID}
  15805.        <--  atpActCount     {number of bytes actually received}
  15806.        <--  atpUserData     {user bytes}
  15807.        <--  atpXO           {exactly-once flag}
  15808.  
  15809.        ATPGetRequest sets up the mechanism to receive a request sent by
  15810. either an ATPSndRequest or an ATPRequest call. ATPSocket contains the
  15811. socket number of the socket that should listen for a request; this socket
  15812. must already have been opened by calling ATPOpenSocket. The address of the socket from which the request was sent is returned in atpAddress.
  15813. ATPDataPtr specifies a buffer to store the incoming request; atpReqCount indicates the size of the buffer in bytes. The number of bytes actually received in the request is returned in atpActCount. ATPUserData contains the user bytes from the ATP header. The transaction bit map is returned in atpBitMap. The transaction ID is returned in atpTransID. ATPXO will be TRUE if the request is part of an exactly-once transaction.
  15814.  
  15815.        ATPGetRequest completes when a request is received. To cancel an
  15816. asynchronous ATPGetRequest call, you must call ATPCloseSocket, but this
  15817. cancels all pending calls involving that socket.
  15818.  
  15819.  
  15820.     Result codes
  15821.  
  15822.             noErr       No error
  15823.             badATPSkt   Bad responding socket
  15824.             sktClosed   Socket closed by a cancel call
  15825. \ ATPSndRsp
  15826. 23
  15827. Function ATPSndRsp (abRecord: ABRecHandle; async: BOOLEAN) :
  15828.                      OSErr;
  15829.  
  15830.  
  15831.     ABusRecord
  15832.     ----------
  15833.        <--  abOpcode        {always tATPSndRsp}
  15834.        <--  abResult        {result code}
  15835.        -->  abUserReference {for your use}
  15836.        -->  atpSocket       {responding socket number}
  15837.        -->  atpAddress      {destination socket address}
  15838.        -->  atpRspBDSPtr    {pointer to response BDS}
  15839.        -->  atpTransID      {transaction ID}
  15840.        -->  atpEOM          {end-of-message flag}
  15841.        -->  atpNumBufs      {number of response packets being sent}
  15842.        -->  atpBDSSize      {number of elements in response BDS}
  15843.  
  15844.  
  15845.        ATPSndRsp sends a response to another socket. ATPSocket contains
  15846. the socket number from which the response should be sent and atpAddress
  15847. contains the internet address of the socket to which the response
  15848. should be sent. ATPTransID must contain the transaction ID. ATPEOM is
  15849. TRUE if the response BDS contains the final packet in a transaction
  15850. composed of a group of packets and the number of packets in the
  15851. response is less than expected. ATPRspBDSPtr points to the buffer data
  15852. structure containing the responses to be sent. ATPBDSSize indicates
  15853. the number of elements in the response BDS, and must be in the range 1
  15854. to 8. ATPNumBufs indicates the number of response packets being sent
  15855. with this call, and must be in the range 0 to 8.
  15856.  
  15857. (note)
  15858.     In some situations, you may want to send only part (or
  15859.     possibly none) of your response message back immediately.
  15860.     For instance, you might be requested to send back seven
  15861.     disk blocks, but have only enough internal memory to
  15862.     store one block. In this case, set atpBDSSize to 7
  15863.     (total number of response packets), atpNumBufs to 0
  15864.     (number of response packets currently being sent), and
  15865.     call ATPSndRsp. Then as you read in one block at a time,
  15866.     call ATPAddRsp until all seven response datagrams have
  15867.     been sent.
  15868.  
  15869.        During exactly-once transactions, ATPSndRsp won't complete until
  15870. the release packet is received or the release timer expires.
  15871.  
  15872.  
  15873.     Result codes
  15874.  
  15875.             noErr       No error
  15876.             badATPSkt   Bad responding socket
  15877.             noRelErr    No release received
  15878.             sktClosed   Socket closed by a cancel call
  15879.             noDataArea  Too many outstanding ATP calls
  15880. \ ATPAddRsp
  15881. 23
  15882. Function ATPAddRsp (abRecord: ABRecHandle): OSErr;
  15883.  
  15884.  
  15885.     ABusRecord
  15886.     ----------
  15887.        <--  abOpcode        {always tATPAddRsp}
  15888.        <--  abResult        {result code}
  15889.        -->  abUserReference {for your use}
  15890.        -->  atpSocket       {responding socket number}
  15891.        -->  atpAddress      {destination socket address}
  15892.        -->  atpReqCount     {buffer size in bytes}
  15893.        -->  atpDataPtr      {pointer to buffer}
  15894.        -->  atpTransID      {transaction ID}
  15895.        -->  atpUserData     {user bytes}
  15896.        -->  atpEOM          {end-of-message flag}
  15897.        -->  atpNumRsp       {sequence number}
  15898.  
  15899.        ATPAddRsp sends one additional response packet to a socket that has already been sent the initial part of a response via ATPSndRsp. ATPSocket contains the socket number from which the response should be sent and atpAddress contains the internet add
  15900.  
  15901. (note)
  15902.     No BDS is needed with ATPAddRsp because all pertinent information is passed within the record.
  15903.  
  15904.  
  15905.     Result codes
  15906.  
  15907.             noErr       No error
  15908.             badATPSkt   Bad responding socket
  15909.             badBuffNum  Bad sequence number
  15910.             noSendResp  ATPAddRsp issued before ATPSndRsp
  15911.             noDataArea  Too many outstanding ATP calls
  15912. \ ATPResponse
  15913. 23
  15914. Function ATPResponse (abRecord: ABRecHandle; async: BOOLEAN) :
  15915.                        OSErr;
  15916.  
  15917.  
  15918.     ABusRecord
  15919.     ----------
  15920.        <--  abOpcode        {always tATPResponse}
  15921.        <--  abResult        {result code}
  15922.        -->  abUserReference {for your use}
  15923.        -->  aptSocket       {responding socket number}
  15924.        -->  atpAddress      {destination socket address}
  15925.        -->  atpRspUData     {user bytes sent in transaction response}
  15926.        -->  atpRspBuf       {pointer to response message buffer}
  15927.        -->  atpRspSize      {size of response message buffer}
  15928.  
  15929.         ATPResponse is functionally analogous to ATPSndRsp. It sends a response to a socket, but doesn't require the caller to provide a BDS. ATPAddress must contain the complete network address of the socket to which the response should be sent (the socket on which the corresponding
  15930. ATPGetRequest was issued). ATPRspBuf points to the buffer containing the response message; the size of this buffer must be passed in
  15931. atpRspSize. The four user bytes to be sent in the ATP header of the first response packet are passed in atpRspUData. The last packet of
  15932. the transaction response is sent with the EOM flag set.
  15933.  
  15934.         Although you don't provide a BDS, ATPResponse in fact creates one and calls the .ATP driver (as in an ATPSndRsp call). For this reason, the abRecord fields atpRspBDSPtr and atpNumBufs are used by ATPResponse; you should not expect these fields to remain unaltered during or after the function's execution.
  15935.  
  15936.     During exactly-once transactions ATPResponse won't complete until the release packet is received or the release timer expires.
  15937.  
  15938. (warning)
  15939.     The maximum permissible size of the response message is
  15940.     4624 bytes.
  15941.  
  15942.  
  15943.     Result codes
  15944.  
  15945.             noErr       No error
  15946.             badATPSkt   Bad responding socket
  15947.             noRelErr    No release received
  15948.             atpLenErr   Response too big
  15949.             sktClosed   Socket closed by a cancel call
  15950.             noDataArea  Too many outstanding ATP calls
  15951. \ ATPRspCancel
  15952. 23
  15953. Function ATPRspCancel (abRecord: ABRecHandle; async: BOOLEAN) :
  15954.                         OSErr;
  15955.  
  15956.         Given the handle to the ABusRecord of a previously made ATPSndRsp or ATPResponse call, ATPRspCancel dequeues the ATPSndRsp or ATPResponse call, provided that the call hasn't already completed. ATPRspCancel returns noErr if the ATPSndRsp or ATPResponse call is successfully removed from the queue. If it returns cbNotFound, check the abResult field of abRecord to verify that the ATPSndRsp or ATPResponse call has been completed and determine its outcome.
  15957.  
  15958.  
  15959.     Result codes
  15960.  
  15961.             noErr       No error
  15962.             cbNotFound  ATP control block not found
  15963.             noDataArea  Too many outstanding ATP calls
  15964. \ NBPRegister
  15965. 23
  15966. Function NBPRegister (abRecord: ABRecHandle; async: BOOLEAN) :
  15967.                         OSErr;
  15968.  
  15969.  
  15970.     ABusRecord
  15971.     ----------
  15972.        <--  abOpcode            {always tNBPRegister}
  15973.        <--  abResult            {result code}
  15974.        -->  abUserReference     {for your use}
  15975.        -->  nbpEntityPtr        {pointer to entity name}
  15976.        -->  nbpBufPtr           {pointer to buffer}
  15977.        -->  nbpBufSize          {buffer size in bytes}
  15978.        -->  nbpAddress.aSocket  {socket address}
  15979.        -->  nbpRetransmitInfo   {retransmission information}
  15980.  
  15981.         NBPRegister adds the name and address of an entity to the node's
  15982. names table. NBPEntityPtr points to a variable of type EntityName
  15983. containing the entity's name. If the name is already registered,
  15984. NBPRegister returns the result code nbpDuplicate. NBPBufPtr and nbpBufSize specify the location and size of a buffer for NBP to use internally. The buffer must contain at least 12 bytes plus the length of the entity name.
  15985.  
  15986. (warning)
  15987.     This buffer must not be altered or released until the
  15988.     name is removed from the names table via an NBPRemove
  15989.     call. If you allocate the buffer through a NewHandle
  15990.     call, the handle must be locked as long as the name is
  15991.     registered.
  15992.  
  15993.     Result codes
  15994.  
  15995.             noErr         No error
  15996.             nbpDuplicate  Duplicate name already exists
  15997. \ NBPLookup
  15998. 23
  15999. Function NBPLookup (abRecord: ABRecHandle; async: BOOLEAN) :
  16000.                         OSErr;
  16001.  
  16002.  
  16003.     ABusRecord
  16004.     ----------
  16005.        <--  abOpcode            {always tNBPLookup}
  16006.        <--  abResult            {result code}
  16007.        -->  abUserReference     {for your use}
  16008.        -->  nbpEntityPtr        {pointer to entity name}
  16009.        -->  nbpBufPtr           {pointer to buffer}
  16010.        -->  nbpBufSize          {buffer size in bytes}
  16011.        <->  nbpDataField        {number of addresses received}
  16012.        -->  nbpRetransmitInfo   {retransmission information}
  16013.  
  16014.     NBPLookup returns the addresses of all entities with a specified name. NBPEntityPtr points to a variable of type EntityName containing the name of the entity whose address should be returned. (Meta-characters are allowed in the entity name.)  NBPBufPtr and NBPBufSize contain the location and size of an area of memory in which the entities' addresses should be returned. NBPDataField indicates the maximum number of matching names to find addresses for; the actual number of addresses
  16015. found is returned in NBPDataField. NBPRetransmitInfo contains the
  16016. retry interval and the retry count.
  16017.  
  16018.     Result codes
  16019.  
  16020.             noErr       No error
  16021.             nbpBuffOvr  Buffer overflow
  16022. \ NBPExtract
  16023. 23
  16024. Function NBPExtract (theBuffer: Ptr; numInBuf: INTEGER; whichOne:
  16025.                     INTEGER; VAR abEntityName; VAR address: AddrBlock)
  16026.                     : OSErr;
  16027.  
  16028.     NBPExtract retruns one address from the list of addresses returned by NBPLookup. TheBuffer and numInBuf indicate the location and number of
  16029. tuples in the buffer. WhichOne specifies which one of the tuples in
  16030. the buffer should be returned in the abEntity and adress parameters.
  16031.  
  16032.     Result codes
  16033.  
  16034.             noErr       No error
  16035.             extractErr  Can't find tuple in buffer
  16036. \ NBPConfirm
  16037. 23
  16038. Function NBPConfirm (abRecord: ABRecHandle; async: BOOLEAN) :
  16039.                         OSErr;
  16040.  
  16041.     ABusRecord
  16042.     ----------
  16043.        <--  abOpcode            {always tNBPConfirm}
  16044.        <--  abResult            {result code}
  16045.        -->  abUserReference     {for your use}
  16046.        -->  nbpEntityPtr        {pointer to entity name}
  16047.        <--  nbpDataField        {number of addresses received}
  16048.        -->  nbpAddress          {socket address}
  16049.        -->  nbpRetransmitInfo   {retransmission information}
  16050.  
  16051.     NBPConfirm confirms that an entity known by name and address still
  16052. exists (is still entered in the names directory). NBPEntityPtr points
  16053. to a variable of type EntityName that contains the name to confirm, and
  16054. nbpAddress specifies the address to be confirmed. (No meta-characters
  16055. are allowed in the entity name.)  NBPRetransmitInfo contains the retry
  16056. interval and the retry count. The correct socket number of the entity
  16057. is returned in nbpDataField. NBPConfirm is more efficient than
  16058. NBPLookup in terms of network traffic.
  16059.  
  16060.  
  16061.     Result codes
  16062.  
  16063.             noErr       No error
  16064.             nbpConfDiff Name confirmed for different socket
  16065.             nbpNoConfirm    Name not confirmed
  16066. \ NBPRemove
  16067. 23
  16068. Function NBPRemove (abEntity: EntityPtr) : OSErr;
  16069.  
  16070.    NBPRemove removes an entity name from the names table of the caller's node.
  16071.  
  16072.  
  16073.     Result codes
  16074.  
  16075.             noErr       No error
  16076.             nbpNotFound Name not found
  16077. \ NBPLoad
  16078. 23
  16079. Function NBPLoad : OSErr;
  16080.  
  16081.     On a Macintosh 128K, NBPLoad reads the AppleTalk Manager's NBP code
  16082. from the system resource file into the application heap. On a Macintosh 512K or XL, NBPLoad has no effect since the NBP code should have already been loaded when the .MPP driver was opened. Normally you'll never need to call NBPLoad because the AppleTalk Manager calls it when necessary.
  16083.  
  16084.     Result codes    noErr       No error
  16085. \ NBPUnload
  16086. 23
  16087. Function NBPUnload : OSErr;
  16088.  
  16089.     NBPUnload makes the NBP code purgeable; the space isn't actually
  16090. released by the Memory Manager until necessary.
  16091.  
  16092. (note)
  16093.     This call applies only to a Macintosh 128K; on a
  16094.     Macintosh 512K or Macintosh XL, NBPUnload has no effect.
  16095.  
  16096.     Result codes    noErr       No error
  16097. \ GetNodeAddress
  16098. 23
  16099. Function GetNodeAddress (VAR myNode,myNet: INTEGER) : OSErr;
  16100.  
  16101.     GetNodeAddress returns the current node ID and network number of the
  16102. caller. If the .MPP driver isn't installed, it returns noMPPErr. If
  16103. myNet contains 0, this means that a bridge hasn't yet been found.
  16104.  
  16105.     Result codes
  16106.  
  16107.             noErr       No error
  16108.             noMPPErr    MP driver not installed
  16109. \ IsMPPOpen
  16110. 23
  16111. Function IsMPPOpen : BOOLEAN;
  16112.  
  16113.     IsMPPOpen returns TRUE if the .MPP driver is loaded and running.
  16114. \ IsATPOpen
  16115. 23
  16116. Function IsATPOpen : BOOLEAN;
  16117.  
  16118.     IsATPOpen returns TRUE if the .ATP driver is loaded and running.
  16119. \ VInstall
  16120. 24
  16121. Function VInstall (vblTaskPtr: QElemPtr) : OSErr;
  16122.  
  16123.     _________________________________________________________________
  16124.  
  16125.     Trap macro  _VInstall
  16126.  
  16127.     On entry    A0:  vblTaskPtr (pointer)
  16128.  
  16129.     On exit     D0:  result code (integer)
  16130.     _________________________________________________________________
  16131.  
  16132.     VInstall adds the task described by vblTaskPtr to the vertical
  16133. retrace queue. Your application must fill in all fields of the task
  16134. except qLink. VInstall returns one of the result codes listed below.
  16135.  
  16136.     Result codes
  16137.  
  16138.             noErr       No error
  16139.             vTypErr     QType field isn't ORD(vType)
  16140.  
  16141. \ VRemove
  16142. 24
  16143. Function VRemove (vblTaskPtr: QElemPtr) : OSErr;
  16144.  
  16145.     _________________________________________________________________
  16146.  
  16147.     Trap macro  _VRemove
  16148.  
  16149.     On entry    A0:  vblTaskPtr (pointer)
  16150.  
  16151.     On exit     D0:  result code (integer)
  16152.     _________________________________________________________________
  16153.  
  16154.  
  16155.     Result codes
  16156.  
  16157.             noErr       No error
  16158.             vTypErr     QType field isn't ORD(vType)
  16159.             qErr        Task entry isn't in the queue
  16160. \ GetVBLQHdr
  16161. 24
  16162. Function GetVBLQHdr : QHdrPtr;   [Pascal only]
  16163.  
  16164.     GetVBLQHdr returns a pointer to the vertical retrace queue.
  16165. \ HandToHand
  16166. 25
  16167. Function HandToHand (VAR theHndl: Handle) : OSErr;
  16168.  
  16169.     _________________________________________________________________
  16170.  
  16171.     Trap macro  _HandToHand
  16172.  
  16173.     On entry    A0:  theHndl (handle)
  16174.  
  16175.     On exit     A0:  theHndl (handle)
  16176.                 D0:  result code (word)
  16177.     __________________________________________________________________
  16178.  
  16179.     HandToHand copies the information to which theHndl is a handle and
  16180. returns a new handle to the copy in theHndl. Since HandToHand replaces
  16181. the input parameter with a new handle, you should retain the original
  16182. value of the input parameter somewhere else, or you won't be able to
  16183. access it. For example:
  16184.  
  16185.     VAR x,y: Handle;
  16186.         err: OSErr;
  16187.  
  16188.     y := x;
  16189.     err := HandToHand(y)
  16190.  
  16191.     The original handle remains in x while y becomes a different handle
  16192. to identical data.
  16193.  
  16194.     Result codes
  16195.  
  16196.             noErr         No error
  16197.             memFullErr    Not enough room in heap
  16198.             nilHandleErr  NIL master pointer
  16199.             memWZErr      Attempt to operate on a free block
  16200. \ PtrToHand
  16201. 25
  16202. Function PtrToHand (srcPtr: Ptr; VAR dstHndl: Handle; size: LONGINT) :
  16203.         OSErr;
  16204.  
  16205.     __________________________________________________________________
  16206.  
  16207.     Trap macro  _PtrToHand
  16208.  
  16209.     On entry    A0:  srcPtr (pointer)
  16210.                 D0:  size (long word)
  16211.  
  16212.     On exit     A0:  dstHndl (handle)
  16213.                 D0:  result code (word)
  16214.     ___________________________________________________________________
  16215.  
  16216.     PtrToHand returns in dstHndl a newly created handle to a copy of the
  16217. number of bytes specified by the size parameter, beginning at the
  16218. location specified by srcPtr.
  16219.  
  16220.     Result codes
  16221.  
  16222.             noErr       No error
  16223.             memFullErr  Not enough room in heap
  16224. \ PtrToXHand
  16225. 25
  16226. Function PtrToXHand (srcPtr: Ptr; dstHndl: Handle; size: LONGINT) :
  16227.                     OSErr;
  16228.  
  16229.  
  16230.     __________________________________________________________________
  16231.  
  16232.     Trap macro  _PtrToXHand
  16233.  
  16234.     On entry    A0:  srcPtr (pointer)
  16235.                 A1:  dstHndl (handle)
  16236.                 D0:  size (long word)
  16237.  
  16238.     On exit     A1:  dstHndl (handle)
  16239.                 D0:  result code (word)
  16240.     ___________________________________________________________________
  16241.  
  16242.     PtrToXHand takes the existing handle specified by dstHndl and makes
  16243. it a handle to a copy of the number of bytes specified by the size
  16244. parameter, beginning at the location specified by srcPtr.
  16245.  
  16246.     Result codes
  16247.  
  16248.             noErr       No error
  16249.             memFullErr  Not enough room in heap
  16250.             nilHandleErr    NIL master pointer
  16251.             memWZErr    Attempt to operate on a free block
  16252. \ HandAndHand
  16253. 25
  16254. Function HandAndHand (aHndl,bHndl: Handle) : OSErr;
  16255.  
  16256.     __________________________________________________________________
  16257.  
  16258.     Trap macro  _HandAndHand
  16259.  
  16260.     On entry    A0:  aHndl (handle)
  16261.                 A1:  bHndl (handle)
  16262.  
  16263.     On exit     A1:  bHndl (handle)
  16264.                 D0:  result code (word)
  16265.     ___________________________________________________________________
  16266.  
  16267.     HandAndHand concatenates the information to which aHndl is a handle
  16268. onto the end of the information to which bHndl is a handle.
  16269.  
  16270.  
  16271.     Result codes
  16272.  
  16273.             noErr       No error
  16274.             memFullErr  Not enough room in heap
  16275.             nilHandleErr    NIL master pointer
  16276.             memWZErr    Attempt to operate on a free block
  16277. \ PtrAndHand
  16278. 25
  16279. Function PtrAndHand (pntr: Ptr; hndlk: Handle; size: LONGINT) : OSErr;
  16280.  
  16281.     __________________________________________________________________
  16282.  
  16283.     Trap macro  _PtrToXHand
  16284.  
  16285.     On entry    A0:  pntr (pointer)
  16286.                 A1:  hndl (handle)
  16287.                 D0:  size (long word)
  16288.  
  16289.     On exit     A1:  hndl (handle)
  16290.                 D0:  result code (word)
  16291.     ___________________________________________________________________
  16292.  
  16293.     PtrAndHand takes the number of bytes specified by the size
  16294. parameter, beginning at the location specified by pntr, and concatenates
  16295. them onto the end of the information to which hndl is a handle.
  16296.  
  16297.     Result codes
  16298.  
  16299.             noErr       No error
  16300.             memFullErr  Not enough room in heap
  16301.             nilHandleErr    NIL master pointer
  16302.             memWZErr    Attempt to operate on a free block
  16303. \ NGetTrapAddress
  16304. 25
  16305. Function NGetTrapAddress (trapNum: INTEGER; tType: TrapType) : LongInt;
  16306.  
  16307.  
  16308.     NGetTrapAddress is identical to GetTrapAddress except that it
  16309. requires you to specify in tType whether the given routine is an
  16310. Operating System or a Toolbox trap.
  16311.  
  16312. Trap macro  _GetTrapAddress ,NEWOS      (bit 9 set, bit 10 clear)
  16313.             _GetTrapAddress ,NEWTOOL    (bit 9 set, bit 10 set)
  16314.  
  16315. On entry    D0:  trapNum (word)
  16316.  
  16317. On exit     A0:  address of routine
  16318. \ NSetTrapAddress
  16319. 25
  16320. Function NSetTrapAddress (trapAddr: LongInt; trapNum: INTEGER;
  16321.                             tType: TrapType);
  16322.  
  16323.     NSetTrapAddress is identical to SetTrapAddress except that it
  16324. requires you to specify in tType whether the given routine is an
  16325. Operating System or a Toolbox trap.
  16326.  
  16327. Trap macro  _SetTrapAddress ,NEWOS      (bit 9 set, bit 10 clear)
  16328.             _SetTrapAddress ,NEWTOOL    (bit 9 set, bit 10 set)
  16329.  
  16330. On entry    A0:  trapAddr (address)
  16331.             D0:  trapNum (word)
  16332. \ RelString
  16333. 25
  16334. Function RelString (aStr,bStr: Str255; caseSens,diacSens: BOOLEAN)
  16335.                     : INTEGER;
  16336.  
  16337.     RelString is similar to EqualString except that it indicates whether
  16338. the first string is less than, equal to, or greater than the second
  16339. string by returning either –1, 0, or 1 respectively.
  16340.  
  16341.  
  16342. Trap macro  _RelString
  16343.             _RelString ,MARKS       (sets bit 9, for diacSens=FALSE)
  16344.             _RelString ,CASE        (sets bit 10, for caseSens=TRUE)
  16345.             _RelString ,MARKS,CASE  (sets bits 9 and 10)
  16346.  
  16347. On entry    A0:  pointer to first character of first string
  16348.             A1:  pointer to first character of second string
  16349.             D0:  high-order word:  length of first string
  16350.                  low-order word:  length of second string
  16351.  
  16352. On exit D0:    –1 if first string less than second,
  16353.                 0 if equal,
  16354.                 1 if first string greater than second (long word)
  16355.  
  16356.  
  16357.     RelString follows the sort order described in chapter 19 of
  16358. Volume II except for the reordering of the following ligatures:
  16359.  
  16360. Æ falls between Å and a
  16361. æ falls between å and B
  16362. Œ falls between Ø and o
  16363. œ falls between ø and P
  16364. ß falls between s and T
  16365.  
  16366.     If diacSens is FALSE, diacritical marks are ignored; RelString
  16367. strips diacriticals according to the following table:
  16368.  
  16369. A   <—  Ä, Å, À, Ã
  16370. C   <—  Ç
  16371. E   <—  É
  16372. N   <—  Ñ
  16373. O   <—  Ö, Õ, Ø
  16374. U   <—  Ü
  16375. a   <—  á, à, â, ä, ã, å, ª
  16376. c   <—  ç
  16377. e   <—  é, è, ê, ë
  16378. i   <—  í, ì, î, ï
  16379. n   <—  ñ
  16380. o   <—  ó, ò, ô, ö, õ, ø, º
  16381. u   <—  ú, ù, û, ü
  16382. y   <—  ÿ
  16383.  
  16384. Note:   This stripping is identical to that performed by the UprString
  16385.         procedure when the diacSens parameter is FALSE.
  16386.  
  16387.     If caseSens is FALSE, the comparison is not case-sensitive;
  16388. RelString performs a conversion from lower-case to upper-case characters
  16389. according to the following table:
  16390.  
  16391. A   <—  a
  16392. . . .   <—  . . .
  16393. Z   <—  z
  16394. À   <—  à
  16395. à  <—  ã
  16396. Ä   <—  ä
  16397. Å   <—  å
  16398. Æ   <—  æ
  16399. Ç   <—  ç
  16400. É   <—  é
  16401. Ñ   <—  ñ
  16402. Ö   <—  ö
  16403. Õ   <—  õ
  16404. Ø   <—  ø
  16405. Œ   <—  œ
  16406. Ü   <—  ü
  16407.  
  16408. Note:   This conversion is identical to that performed by the UprString
  16409.         procedure.
  16410.  
  16411. \ Environs
  16412. 25
  16413. Procedure Environs (VAR rom,machine: INTEGER)
  16414.  
  16415.     In the rom parameter, Environs returns the current ROM version
  16416. number (for a Macintosh XL, the version number of the ROM image
  16417. installed by MacWorks). To use the 128K ROM  information described
  16418. in this volume, the version number should be greater than or equal
  16419. to 117 ($75). In the machine parameter, Environs returns an indication
  16420. of which machine is in use, as follows:
  16421.  
  16422.  
  16423. CONST   macXLMachine    = 0;    {Macintosh XL}
  16424.         macMachine      = 1;    {Macintosh 128K, 512K, 512K upgraded, }
  16425.                                 { 512K enhanced, or Macintosh Plus}
  16426.         mac2Machine     = 2;    {Macintosh ][}
  16427.  
  16428. Note:  The machine parameter does not distinguish between the Macintosh
  16429. 128K, 512K, 512K upgraded, 512K enhanced, and Macintosh Plus.
  16430. ________________________________________________________________________
  16431.  
  16432. Assembly-language note:  From assembly language, you can get this
  16433. information from the word that’s at an offset of 8 from the beginning
  16434. of ROM (which is stored in the global variable ROMBase). The format of
  16435. this word is $00xx for the Macintosh 128K, 512K, 512K upgraded, 512K
  16436. enhanced, or Macintosh Plus, and $xxFF for the Macintosh XL, where xx
  16437. is the ROM version number. (The ROM version number will always be
  16438. between $01 and $FE.)
  16439. ________________________________________________________________________
  16440.  
  16441. \ EqualString
  16442. 25
  16443. Function EqualString (aStr,bStr: Str255; caseSens,diacSens: BOOLEAN) :
  16444.                         BOOLEAN;
  16445.  
  16446.     _________________________________________________________________
  16447.  
  16448.     Trap macro  _CmpString
  16449.                 _CmpString  ,MARKS          (sets bit 9, for
  16450.                                              diacSens=FALSE)
  16451.                 _CmpString  ,CASE           (sets bit 10, for
  16452.                                              caseSens=TRUE)
  16453.                 _CmpString   ,MARKS,CASE    (sets bits 9 and 10)
  16454.  
  16455.  
  16456.     On entry    A0:  pointer to first character of first string
  16457.                 A1:  pointer to first character of second string
  16458.                 D0:  high-order word: length of first string
  16459.                      low-order word:  length of second string
  16460.  
  16461.     On exit     D0:  0 if strings equal, 1 if strings not equal
  16462.                     (long word)
  16463.     ___________________________________________________________________
  16464.  
  16465.     EqualString compares the two given strings for equality on the basis
  16466. of their ASCII values. If caseSens is TRUE, uppercase characters are
  16467. distinguished from the corresponding lowercase characters. If diacSens
  16468. is FALSE, diacritical marks are ignored dring the comparison. The
  16469. Function returns TRUE if the strings are equal.
  16470.  
  16471. (note)
  16472.     See also the International Utilities Package function
  16473.     IUEqualString, as described in the Macintosh Packages
  16474.     manual.
  16475. \ UprString
  16476. 25
  16477. Procedure UprString (VAR theString: Str255; diacSens: BOOLEAN);
  16478.  
  16479.     _________________________________________________________________
  16480.  
  16481.     Trap macro  _UprString
  16482.                 _UprString  ,MARKS  (sets bit 9, for diacSens=FALSE)
  16483.  
  16484.     On entry    A0:  pointer to first charactaer of string
  16485.                 D0:  length of string (word)
  16486.  
  16487.     On exit     A0:  pointer to first character of string
  16488.     __________________________________________________________________
  16489.  
  16490.     UprString converts any lowercase letters in the given string to
  16491. uppercase, returning the converted string in theString. In addition,
  16492. diacritical marks are stripped from the string if diacSens is FALSE.
  16493. \ ReadDateTime
  16494. 25
  16495. Function ReadDateTime (VAR secs: LONGINT) : OSErr;
  16496.  
  16497.     __________________________________________________________________
  16498.  
  16499.     Trap macro  _ReadDateTime
  16500.  
  16501.     On entry    A0:  pointer to long word secs
  16502.  
  16503.     On exit     A0:  pointer to long word secs
  16504.                 D0:  result code (word)
  16505.     __________________________________________________________________
  16506.  
  16507.     ReadDateTime copies the date and time stored in the clock chip to a
  16508. low-memory location and returns it in the secs parameter. This routine
  16509. is called at system startup; you'll probably never need to call it
  16510. yourself. Instead you'll call GetDateTime (see below).
  16511.  
  16512.     __________________________________________________________________
  16513.  
  16514.     Assembly-language note:  The low-memory location to which
  16515.     ReadDateTime copies the date and time is the global variable
  16516.     Time.
  16517.     __________________________________________________________________
  16518.  
  16519.  
  16520.     Result codes    noErr       No error
  16521.                     clkRdErr    Unable to read clock
  16522. \ GetDateTime
  16523. 25
  16524. Procedure GetDateTime (VAR secs: LONGINT);
  16525.  
  16526.     GetDateTime returns in the secs parameter the contents of the low-
  16527. memory location in which the date and time is stored; if the date and
  16528. time is properly set, secs will contain the number of seconds between
  16529. midnight, January 1, 1904 and the time that the function was called.
  16530.  
  16531. (note)
  16532.     If your application disables interrupts for longer than a
  16533.     second, the number of seconds returned will not be exact.
  16534.  
  16535.  
  16536.  
  16537.     ________________________________________________________________
  16538.  
  16539.     Assembly-language note:  Assembly-language programmers can just
  16540.     access the global variable Time.
  16541.     ________________________________________________________________
  16542.  
  16543.     If you wish, you can convert the value returned by GetDateTime to a
  16544. date/time record by calling the Secs2Date procedure.
  16545.  
  16546. (note)
  16547.     Passing the value returned by GetDateTime to the
  16548.     International Utilities Package procedure IUDateString or
  16549.     IUTimeString will yield a string representing the
  16550.     corresponding date or time of day, respectively.
  16551. \ SetDateTime
  16552. 25
  16553. Function SetDateTime (secs: LONGINT) : OSErr;
  16554.  
  16555.     _________________________________________________________________
  16556.  
  16557.     Trap macro  _SetDateTime
  16558.  
  16559.     On entry    D0:  secs (long word)
  16560.  
  16561.     On exit     D0:  result code (word)
  16562.     _________________________________________________________________
  16563.  
  16564.     SetDateTime takes a number of seconds since midnight, January 1,1904
  16565. as specified by the secs parameter and writes it to the clock chip as
  16566. the current date and time. It then attempts to read the value just
  16567. written and verify it by comparing it to the secs parameter.
  16568.  
  16569.     _________________________________________________________________
  16570.  
  16571.     Assembly-language note:  SetDateTime updates the global variable
  16572.     Time to the value of the secs parameter.
  16573.     _________________________________________________________________
  16574.  
  16575.  
  16576.     Result codes    noErr       No error
  16577.                     clkWrErr    Time written did not verify
  16578.                     clkRdErr    Unable to read clock
  16579. \ Date2Secs
  16580. 25
  16581. Procedure Date2Secs (date: DateTimeRec; VAR secs: LONGINT);
  16582.  
  16583.     _________________________________________________________________
  16584.  
  16585.     Trap macro  _Date2Secs
  16586.  
  16587.     On entry    A0:  pointer to date/time record
  16588.  
  16589.     On exit     D0:  secs (long word)
  16590.     _________________________________________________________________
  16591.  
  16592.     Date2Secs takes the given date/time record, converts it to the
  16593. corresponding number of seconds elapsed since midnight, January 1,
  16594. 1904, and returns the result in the secs parameter. The dayOfWeek
  16595. field of the date/time record is ignored. The values passed in the
  16596. year and month fields should be within their allowable ranges, or
  16597. unpredictable results may occur. The remaining four fields of the
  16598. date/time record may contain any value. For example, September 35 will
  16599. be interpreted as October 4, and you could specify the 300th day of the
  16600. year as January 300.
  16601. \ Secs2Date
  16602. 25
  16603. Procedure Secs2Date (secs: LONGINT; VAR date: DateTimeRec);
  16604.  
  16605.     ________________________________________________________________
  16606.  
  16607.     Trap macro  _Secs2Date
  16608.  
  16609.     On entry    D0:  secs (long word)
  16610.  
  16611.     On exit     A0:  pointer to date/time record
  16612.     ________________________________________________________________
  16613.  
  16614.  
  16615.     Secs2Date takes a number of seconds elapsed since midnight,
  16616. January 1, 1904 as specified by the secs parameter, converts it to the
  16617. corresponding date and time, and returns the corresponding date/time
  16618. record in the date parameter.
  16619. \ GetTime
  16620. 25
  16621. Procedure GetTime (VAR date: DateTimeRec);
  16622.  
  16623.     GetTime takes the number of seconds elapsed since midnight,
  16624. January 1, 1904 (obtained by calling GetDateTime), converts that value
  16625. into a date and time (by calling Secs2Date), and returns the result in
  16626. the date parameter.
  16627. \ SetTime
  16628. 25
  16629. Procedure SetTime (date: DateTimeRec);
  16630.  
  16631.     SetTime takes the date and time specified by the date parameter,
  16632. converts it into the corresponding number of seconds elapsed since
  16633. midnight, January 1, 1904 (by calling Date2Secs), and then writes that
  16634. value to the clock chip as the current date time (by calling
  16635. SetDateTime).
  16636. \ InitUtil
  16637. 25
  16638. Function InitUtil : OSErr;
  16639.  
  16640.     _________________________________________________________________
  16641.  
  16642.     Trap macro  _InitUtil
  16643.  
  16644.     On exit     D0:  result code (word)
  16645.     _________________________________________________________________
  16646.  
  16647.  
  16648.     InitUtil copies the contents of parameter RAM into 20 bytes of low
  16649. memory and copies the date and time from the clock chip into its own
  16650. low-memory location. This routine is called at system startup; you'll
  16651. probably never need to call it yourself.
  16652.  
  16653.  
  16654.     _________________________________________________________________
  16655.  
  16656.     Assembly-language note:  InitUtil copies parameter RAM into 20
  16657.     bytes starting at the address SysParam and copies the date and
  16658.     time into the global variable Time.
  16659.     _________________________________________________________________
  16660.  
  16661.     If the validity status in parameter RAM is not $A8 when InitUtil is
  16662. called, an error is returned as the result code, and the default values
  16663. (given earlier in the "ParameterRAM" section) are read into the los-
  16664. memory copy of parameter RAM; these values are then written to the
  16665. clock chip itself.
  16666.  
  16667.     Result codes    noErr       No error
  16668.                     prInitErr   Validity status not $A8
  16669. \ GetSysPPtr
  16670. 25
  16671. Function GetSysPPtr : SysPPtr;
  16672.  
  16673.     GetSysPPtr returns a pointer to the low-memory copy of parameter
  16674. RAM. You can examine the values stored in its various fields, or to
  16675. change them before calling WriteParam (below).
  16676. \ WriteParam
  16677. 25
  16678. Function WriteParam : OSErr;
  16679.  
  16680.     _________________________________________________________________
  16681.  
  16682.     Trap macro  _WriteParam
  16683.  
  16684.     On entry    A0:  SysParam (pointer)
  16685.                 D0:  MinusOne (long word)
  16686.  
  16687.                  (You have to pass the values of these global
  16688.                   variables for historical reasons.)
  16689.  
  16690.     On exit     D0:  result code (word)
  16691.     _________________________________________________________________
  16692.  
  16693.  
  16694.     WriteParam writes the low-memory copy of parameter RAM to the clock
  16695. chip. You should previously have called GetSysPPtr and changed
  16696. selected values as desired.
  16697.  
  16698.     WriteParam also attempts to verify the values written by reading
  16699. them back in and comparing them to the values in the low-memory copy.
  16700.  
  16701. (note)
  16702.     If you've accidentally written incorrect values into
  16703.     parameter RAM, the system may not be able to start up.
  16704.     If this happens, you can reset parameter RAM by removing
  16705.     the battery, letting the Macintosh sit turned off for
  16706.     about five minutes, and then putting the battery back in.
  16707.  
  16708.  
  16709.     Result code noErr       No error
  16710.                 prWrErr     Parameter RAM written did not verify
  16711. \ Enqueue
  16712. 25
  16713. Procedure Enqueue (qElement: QElemPtr; theQueue: QHdrPtr);
  16714.  
  16715.     ________________________________________________________________
  16716.  
  16717.     Trap macro  _Enqueue
  16718.  
  16719.     On entry    A0:  qElement (pointer)
  16720.                 A1:  theQueue (pointer)
  16721.  
  16722.     On exit     A1:  theQueue (pointer)
  16723.     ________________________________________________________________
  16724.  
  16725.     Enqueue adds the queue entry pointer to by qElement to the end of
  16726. the queue specified by theQueue.
  16727.  
  16728. (note)
  16729.     Interrupts are disabled for a short time while the queue
  16730.     is updated.
  16731. \ Dequeue
  16732. 25
  16733. Function Dequeue (qElement: QElemPtr; theQueue: QHdrPtr) : OSErr;
  16734.  
  16735.     _________________________________________________________________
  16736.  
  16737.     Trap macro  _Dequeue
  16738.  
  16739.     On entry    A0:  qElement (pointer)
  16740.                 A1:  theQueue (pointer)
  16741.  
  16742.     On exit     A1:  theQueue (pointer)
  16743.                 D0:  result code (word)
  16744.     _________________________________________________________________
  16745.  
  16746.  
  16747.     Dequeue removes the queue entry pointed to by qElement from the
  16748. queue specified by theQueue (without deallocating the entry) and adjusts
  16749. other entries in the queue accordingly.
  16750.  
  16751. (note)
  16752.     The note under Enqueue above also applies here. In this
  16753.     case, the amount of time interrupts are disabled depends
  16754.     on the length of the queue and the position of the entry
  16755.     in the queue.
  16756.  
  16757. (note)
  16758.     To remove all entries from a queue, you can just clear
  16759.     all the fields of the queue's header.
  16760.  
  16761.  
  16762.     Result codes    noErr       No error
  16763.                     qErr        Entry not in specified queue
  16764.  
  16765.  
  16766.  
  16767.  
  16768. \ GetTrapAddress
  16769. 25
  16770. Function GetTrapAddress (trapNum: INTEGER) : LONGINT;
  16771.  
  16772.     _________________________________________________________________
  16773.  
  16774.     Trap macro  _GetTrapAddress
  16775.  
  16776.     On entry    D0:  trapNum (word)
  16777.  
  16778.     On exit     A0:  address of routine
  16779.     _________________________________________________________________
  16780.  
  16781.  
  16782.     GetTrapAddress returns the address of a routine currently installed
  16783. in the trap dispatch table under the trap number designated by trapNum.
  16784. To find out the trap number for a particular routine, see Appendix B.
  16785. \ SetTrapAddress
  16786. 25
  16787. Procedure SetTrapAddress (trapAddr: LONGINT; trapNum: INTEGER);
  16788.  
  16789.  
  16790.     _________________________________________________________________
  16791.  
  16792.     Trap macro  _SetTrapAddress
  16793.  
  16794.     On entry    A0:  trapAddr (address)
  16795.                 D0:  trapNum (word)
  16796.     _________________________________________________________________
  16797.  
  16798.  
  16799.     SetTrapAddress installs in the trap dispatch table a routine whose
  16800. address is trapAddr; this routine is installed under the trap number
  16801. designated by trapNum.
  16802.  
  16803. (note)
  16804.     Remember, the trap dispatch table can address locations
  16805.     within a range of 64K bytes from the base address of ROM
  16806.     or RAM.
  16807. \ Delay
  16808. 25
  16809. Procedure Delay (numTicks: LONGINT; VAR finalTicks: LONGINT);
  16810.  
  16811.     _______________________________________________________________
  16812.  
  16813.     Trap macro  _Delay
  16814.  
  16815.     On entry    A0:  numTicks (long word)
  16816.  
  16817.     On exit     D0:  finalTicks (long word)
  16818.     _______________________________________________________________
  16819.  
  16820.     Delay causes the system to wait for the number of ticks (sixtieths
  16821. of a second) specified by numTicks, and returns in finalTicks the total
  16822. number of ticks from system startup to the end of the delay.
  16823.  
  16824. (warning)
  16825.     Do not rely on the duration of the delay being exact; it
  16826.     will usually be accurate within one tick, but may be off
  16827.     more than that. The Delay procedure enables all
  16828.     interrupts and checks the tick count that's incremented
  16829.     during the vertical retrace interrupt; however, it's
  16830.     possible for this interrupt to be disabled by other
  16831.     interrupts, in which case the duration of the delay will
  16832.     not be exactly what you requested.
  16833. \ SysBeep
  16834. 25
  16835. Procedure SysBeep (duration: INTEGER);
  16836.  
  16837.     SysBeep causes the system to beep for approximately the number of
  16838. ticks specified by the duration parameter. The sound decays from loud
  16839. to soft; after about five seconds it's inaudible. The initial volume of
  16840. the beep depends on the current speaker volume setting, which the user
  16841. can adjust with the Control Panel desk accessory. If the speaker
  16842. volume has been set to 0 (silent), SysBeep instead causes the menu bar
  16843. to blink once.
  16844. \ Restart
  16845. 25
  16846. Procedure Restart;
  16847.      This procedure restarts the system.
  16848.  
  16849.    _________________________________________________________________
  16850.       Assembly-language note: From assembly language, you can give
  16851.       the following instructions to restart the system:
  16852.  
  16853.           move    ROMBase,A0
  16854.           jmp     $0A(A0)
  16855.    _________________________________________________________________
  16856. \ SetUpA5
  16857. 25
  16858. Procedure SetUpA5;
  16859.  
  16860.      SetUpA5 saves the current value of register A5 (for restoring later
  16861. with RestoreA5, described below) and then resets A5 to point to the
  16862. boundary between the application globals and the application parameters.
  16863. This procedure is useful only within the interrupt environment, where the
  16864. state of A5 is unpredicatble; for instance, in a completion routine or a
  16865. VBL Task, calling SetUpA5 will ensure that A5 contains the proper value,
  16866. allowing the routine or task to access the application globals.
  16867.    _________________________________________________________________
  16868.        Assembly-language note: You can get the boundary between the
  16869.        application globals and the application parameters from the
  16870.        global variable CurrentA5.
  16871.    _________________________________________________________________
  16872. \ RestoreA5
  16873. 25
  16874. Procedure RestoreA5;
  16875.  
  16876.      Call RestoreA5 at the conclusion of a routine or task that required
  16877. a call to SetUpA5; it restores register A5 to whatever its value was when
  16878. SetUpA5 was called.
  16879. \ LNew
  16880. 26
  16881. Function LNew (rView,dataBounds: Rect; cSize: Point; theProc: INTEGER;
  16882.                 theWindow: WindowPtr; drawIt,hasGrow,
  16883.                 scrollHoriz,scrollVert: BOOLEAN) : ListHandle;
  16884.  
  16885.     Call LNew to create a new list. It returns a handle to the new list.
  16886. The list’s grafPort is set to theWindow’s port. If drawIt is FALSE,
  16887. the list is not displayed.
  16888.  
  16889.     RView specifies, in the local coordinates of theWindow, the
  16890. rectangle in which the list will be displayed. (Remember that this
  16891. doesn’t include space for scroll bars. If the list, including scroll
  16892. bars, is to fill the entire window, rView should be 15 points smaller in
  16893. each dimension than theWindow’s portRect.)
  16894.  
  16895.     DataBounds is the rectangle for specifying the initial array
  16896. dimensions of the list. For example to preallocate space for a list
  16897. that’s 5 cells across by 10 cells down, you should set dataBounds to
  16898. (0,0)(5,10). If you want to allocate the space for a one-column list,
  16899. set dataBounds to (0,0)(1,0) and use LAddRow.
  16900.  
  16901.     CSize.h and cSize.v are the desired height and width of each cell in
  16902. pixels; if they’re not specified, a default cell size is calculated
  16903. (as described above).
  16904.  
  16905.     TheProc is the resource ID of your list definition procedure; for
  16906. a text-only list, pass 0 and the default list definition procedure
  16907. (about 150 bytes in size) will be used. The list definition procedure
  16908. is called to initialize itself after all other list record fields have
  16909. been initialized; thus, it can use any of the values in the list record
  16910. (or set particular fields, such as the indent distance).
  16911.  
  16912.     If hasGrow is TRUE, the scroll bars are sized so that there’s room
  16913. for a size box in the standard position. It’s up to the program to
  16914. display the size box (using the Window Manager procedure DrawGrowIcon).
  16915. If scrollHoriz is TRUE, a horizontal scroll bar is placed immediately
  16916. below rView and all horizontal scrolling functions are implemented.
  16917. If scrollVert is TRUE, a vertical scroll bar is placed immediately to
  16918. the right of rView and all vertical scrolling functions are implemented.
  16919.  
  16920.     The visible rectangle is set to contain as many cells of cSize
  16921. (or the default) as will fit into rView. If the cells do not fit
  16922. exactly into rView, the visible rectangle is rounded up to the nearest
  16923. cell. Scrolling will always allow all cells to be fully displayed.
  16924. The selection flags are set to 0, and the active flag is set to TRUE.
  16925.  
  16926.  
  16927. Note:  Scrolling looks best if rView is a multiple of cSize.v in height.
  16928.  
  16929. \ LDispose
  16930. 26
  16931. Procedure LDispose (lHandle: ListHandle);
  16932.  
  16933.     Call LDispose when you are through using a list. It issues a close
  16934. call to the list definition procedure, and calls the Memory Manager
  16935. Procedure DisposHandle for the data handle, the Control Manager
  16936. Procedure DisposeControl for both scroll bars (if they’re there), and
  16937. DisposHandle for the list record.
  16938.  
  16939. Note:  Calling LDispose is much faster than deleting one row at a time.
  16940.  
  16941. \ LAddColumn
  16942. 26
  16943. Function LAddColumn (count,colNum: INTEGER; lHandle: ListHandle)
  16944.                     : INTEGER;
  16945.  
  16946.     LAddColumn inserts into the given list the number of columns
  16947. specified by the count parameter, starting at the column specified by
  16948. colNum. Column numbers that are greater than or equal to colNum are
  16949. increased by count. If colNum is not within dataBounds, new last
  16950. columns are added. The number of the first added column is returned
  16951. and dataBounds.right is increased by count. All cells added are empty.
  16952. If there are no cells (because dataBounds.top = dataBounds.bottom), no
  16953. cells are added, but dataBounds is still extended. If drawing is on and
  16954. the added columns (which are empty) are visible, the list and its
  16955. scrollbars are updated.
  16956.  
  16957. \ LAddRow
  16958. 26
  16959. Function LAddRow (count,rowNum: INTEGER; lHandle: ListHandle) : INTEGER;
  16960.  
  16961.     LAddRow inserts the number of rows specified by the count parameter,
  16962. starting at the row specified by rowNum. Row numbers that are greater
  16963. than or equal to rowNum are increased by count. If rowNum is not within
  16964. dataBounds, new last rows are added. The number of the first added row
  16965. is returned, and dataBounds.bottom is increased by count. All cells
  16966. added are empty. If there are no cells (because dataBounds.left =
  16967. dataBounds.right), no cells are added, but dataBounds is still extended.
  16968. If drawing is on and the added rows (which are empty) are visible, the
  16969. list and its scroll bars are updated.
  16970.  
  16971. \ LDelColumn
  16972. 26
  16973. Procedure LDelColumn (count,colNum: INTEGER; lHandle: ListHandle);
  16974.  
  16975.     LDelColumn deletes the number of columns specified by the count
  16976. parameter, starting with the column specified by colNum. Column
  16977. numbers that are greater than colNum are decreased by count. If colNum
  16978. is not within dataBounds, nothing is done. DataBounds.right is
  16979. decreased by count. If drawing is on and the deleted columns were
  16980. visible, the list and its scroll bars are updated.
  16981.  
  16982.     If count is 0, or colNum = dataBounds.left AND count  > =
  16983. dataBounds.right – dataBounds.left all the data in the list is quickly
  16984. deleted, dataBounds.right is set to dataBounds.left, and the number of
  16985. rows is left unchanged.
  16986.  
  16987. \ LDelRow
  16988. 26
  16989. Procedure LDelRow (count,rowNum: INTEGER; lHandle: ListHandle);
  16990.  
  16991.     LDelRow deletes the number of rows specified by the count parameter,
  16992. starting with the row specified by rowNum. Row numbers that are greater
  16993. than rowNum are decreased by count. If rowNum is not within dataBounds,
  16994. nothing is done. DataBounds.bottom is decreased by count. If drawing
  16995. is on and the deleted rows were visible, the list and its scroll bars
  16996. are updated.
  16997.  
  16998.     If count is 0, or rowNum = dataBounds.top AND count > =
  16999. dataBounds.bottom – dataBounds.top all the data in the list is quickly
  17000. deleted, dataBounds.bottom is set to dataBounds.top, and the number of
  17001. columns is left unchanged.
  17002.  
  17003. \ LAddToCell
  17004. 26
  17005. Procedure LAddToCell (dataPtr: Ptr; dataLen: INTEGER; theCell: Cell;
  17006.                         lHandle: ListHandle);
  17007.  
  17008.     LAddToCell appends the data pointed to by dataPtr and of length
  17009. dataLen to the cell specified by theCell in lHandle. If drawing is off,
  17010. you must turn drawing on and call LDraw (or LUpdate) to display the
  17011. cell’s new value.
  17012.  
  17013. \ LClrCell
  17014. 26
  17015. Procedure LClrCell (theCell: Cell; lHandle: ListHandle);
  17016.  
  17017.     LClrCell clears the contents of the specified cell (by setting the
  17018. length to 0). If theCell is not a valid cell, nothing is done. If
  17019. drawing is off, you must turn drawing on and call LDraw to display
  17020. the cell’s new value (or simply call the Window Manager procedure
  17021. InvalRect).
  17022.  
  17023. \ LGetCell
  17024. 26
  17025. Procedure LGetCell (dataPtr: Ptr; VAR dataLen: INTEGER; theCell: Cell;
  17026.                     lHandle: ListHandle);
  17027.  
  17028.     Given a cell in theCell, LGetCell copies the cell’s data to the
  17029. location specified by dataPtr; dataLen is the maximum number of bytes
  17030. allowed. If the data is longer than dataLen, only dataLen bytes are
  17031. copied into the location specified by dataPtr. If the data is shorter
  17032. than dataLen, dataLen is set to the true length of the cell’s data.
  17033.  
  17034. \ LSetCell
  17035. 26
  17036. Procedure LSetCell (dataPtr: Ptr; dataLen: INTEGER; theCell: Cell;
  17037.                     lHandle: ListHandle);
  17038.  
  17039.     LSetCell places the data pointed to by dataPtr and of length dataLen
  17040. into the specified cell. It replaces any data that was already in the
  17041. cell. If dataLen is 0, this is equivalent to LClrCell. If theCell is
  17042. not a valid cell, nothing is done. If drawing is off, you must turn
  17043. drawing on and call LDraw (or LUpdate) to display the cell’s new value.
  17044.  
  17045. \ LCellSize
  17046. 26
  17047. Procedure LCellSize (cSize: Point; lHandle: ListHandle);
  17048.  
  17049.     LCellSize sets the cellSize field in the list record to cSize and
  17050. updates the visible rectangle to contain cells of this size. This
  17051. command should be used only before any cells have been drawn.
  17052.  
  17053. \ LGetSelect
  17054. 26
  17055. Function LGetSelect (next: BOOLEAN; VAR theCell: Cell;
  17056.                     lHandle: ListHandle) : BOOLEAN;
  17057.  
  17058.     If next is FALSE, LGetSelect returns TRUE if the specified cell is
  17059. selected, or FALSE if not. If next is TRUE, LGetSelect returns in c the
  17060. cell coordinates of the next selected cell in the row that is greater
  17061. than or equal to theCell. If there are no more cells in the row, it
  17062. returns in theCell the cell coordinates of the next selected cell in the
  17063. next row. If there are no more rows, FALSE is returned.
  17064.  
  17065. \ LSetSelect
  17066. 26
  17067. Procedure LSetSelect (setIt: BOOLEAN; theCell: Cell;
  17068.                         lHandle: ListHandle);
  17069.  
  17070.     If setIt is TRUE, LSetSelect selects the cell and redraws if it is
  17071. visible and was previously unselected. If setIt is FALSE, it deselects
  17072. the cell and redraws if necessary.
  17073.  
  17074. \ LClick
  17075. 26
  17076. Function LClick (pt: Point; modifiers: INTEGER; lHandle: ListHandle)
  17077.                     : BOOLEAN;
  17078.  
  17079.     Call LClick when there is a mouse-down event in the destination
  17080. rectangle or its scroll bars. Pt is the mouse location in local
  17081. coordinates. Modifiers is the modifiers word from the event record.
  17082. LHandle is the list to be tracked. The result is TRUE if a double-click
  17083. occurred (and the two clicks took place within the same cell).
  17084.  
  17085.     LClick keeps control until the mouse is released; each time through
  17086. its inner loop, it calls the routine whose pointer is in the lClikLoop
  17087. field of the list record.
  17088.  
  17089.     If the mouse is in the visible rectangle, cells are selected
  17090. according to the state of the modifiers and the selection flags. If the
  17091. mouse was in the cells but is dragged outside the list’s rectangle, the
  17092. list is auto-scrolled. If the mouse was in a control, the control’s
  17093. definition procedure is called to track the mouse. To discover which
  17094. cell was clicked in, use the LLastClick function.
  17095.  
  17096. \ LLastClick
  17097. 26
  17098. Function LLastClick (lHandle: ListHandle) : Cell;
  17099.  
  17100.     LLastClick returns the cell coordinates of the last cell clicked in.
  17101. If no cell has been clicked in since LNew, the value returned (for both
  17102. integers) is negative.
  17103.  
  17104. Note:   The value returned by this call is not the last cell
  17105.         double-clicked in, or the last cell selected, but merely the
  17106.         last cell clicked in.
  17107.  
  17108. \ LFind
  17109. 26
  17110. Procedure LFind (VAR offset,len: INTEGER; theCell: Cell;
  17111.                     lHandle: ListHandle);
  17112.  
  17113.     Given a cell in theCell, LFind returns the offset and the length in
  17114. bytes of the cell’s data. If an invalid cell is specified, offset and
  17115. len are set to –1. A similar procedure, LGetCell, is more convenient to
  17116. use from Pascal.
  17117.  
  17118. \ LNextCell
  17119. 26
  17120. Function LNextCell (hNext,vNext: BOOLEAN; VAR theCell: Cell;
  17121.                     lHandle: ListHandle) : BOOLEAN;
  17122.  
  17123.     Given a cell in theCell, LNextCell returns in theCell the next cell
  17124. in the list. If both hNext and vNext are TRUE, theCell is first
  17125. advanced to the next cell in the row. If there are no more cells in the
  17126. row, theCell is set to the first cell in the next row. If there are no
  17127. more rows, FALSE is returned. If only hNext is TRUE, theCell is
  17128. advanced within the current row. If only vNext is TRUE, theCell is
  17129. advanced within the current column. FALSE is returned if there are no
  17130. remaining cells in the row or column.
  17131.  
  17132. \ LRect
  17133. 26
  17134. Procedure LRect (VAR cellRect: Rect; theCell: Cell; lHandle: ListHandle)
  17135.  
  17136.     LRect returns in cellRect the local (QuickDraw) coordinates of the
  17137. cell specified by theCell. If an invalid cell is specified, (0,0)(0,0)
  17138. is returned in cellRect.
  17139.  
  17140. \ LSearch
  17141. 26
  17142. Function LSearch (dataPtr: Ptr; dataLen: INTEGER; searchProc: Ptr;
  17143.                     VAR theCell: Cell; lHandle: ListHandle) : BOOLEAN;
  17144.  
  17145.     LSearch searches for the first cell greater than or equal to theCell
  17146. that contains the specified data. If a cell containing matching data is
  17147. found, the function result TRUE is returned, and the cell coordinates
  17148. are returned in theCell. If searchProc is NIL, the International
  17149. Utilities Package function IUMagIDString is called to compare the
  17150. specified data with the contents of each cell. If searchProc is not
  17151. NIL, the routine pointed to by searchProc is called.
  17152.  
  17153. Note:  Your searchProc should have the same parameters as the
  17154.         IUMagIDString function.
  17155.  
  17156. \ LSize
  17157. 26
  17158. Procedure LSize (listWidth,listHeight: INTEGER; lHandle: ListHandle);
  17159.  
  17160.     You’ll usually call LSize immediately after the Window Manager
  17161. Procedure SizeWindow. It causes the bottom right of the list to be
  17162. adjusted so that the list is the width and height indicated by listWidth
  17163. and listHeight. The contents of the list and the scroll bars are
  17164. adjusted and redrawn as necessary. The values of listWidth and
  17165. listHeight do not include the scroll bars; for a list that entirely
  17166. fills the window, listWidth and listHeight should be 15 less than the
  17167. portRect if both scroll bars are present.
  17168.  
  17169. \ LDraw
  17170. 26
  17171. Procedure LDraw (theCell: Cell; lHandle: ListHandle);
  17172.  
  17173.     Call LDraw after updating a cell’s data or selection status. (You
  17174. can achieve the same result by invalidating the cell’s rectangle and
  17175. calling LUpdate in response to the update event.)  The List Manager
  17176. makes its grafPort the current port, sets the clipping region to
  17177. the cell’s rectangle, and calls the list definition procedure to draw
  17178. the cell. It restores the clipping region and port before exiting.
  17179.  
  17180. \ LDoDraw
  17181. 26
  17182. Procedure LDoDraw (drawIt: BOOLEAN; lHandle: ListHandle);
  17183.  
  17184.     LDoDraw sets the List Manager’s drawing mode to the state specified
  17185. by drawIt. If drawIt is TRUE, changes made by most List Manager calls
  17186. will cause some sort of drawing to take place. If drawIt is FALSE, all
  17187. cell drawing is disabled. (Two exceptions:  The scroll bars are still
  17188. updated after LSize, and the scroll arrows are still highlighted if the
  17189. user clicks them.)
  17190.  
  17191.     The recommended use of LDoDraw is to disable drawing while you’re
  17192. building a list (that is, adding rows or columns, setting or changing
  17193. cell values, or setting default selections). Once you’ve finished
  17194. building the list, you should then re-enable drawing. In general,
  17195. drawing should be on while you’re in your event loop and dispatching
  17196. events to the List Manager.
  17197.  
  17198. \ LScroll
  17199. 26
  17200. Procedure LScroll (dCols,dRows: INTEGER; lHandle: ListHandle);
  17201.  
  17202.     LScroll scrolls the given list by the number of columns and rows
  17203. specified in dCols and dRows, either positively (down and to the right)
  17204. or negatively (up and to the left). Scrolling is pinned to the list’s
  17205. dataBounds. If drawing is on, LScroll does all necessary updating of
  17206. the screen.
  17207.  
  17208. \ LAutoScroll
  17209. 26
  17210. Procedure LAutoScroll   (lHandle: ListHandle);
  17211.  
  17212.     For the given list, LAutoScroll scrolls the list until the first
  17213. selected cell is visible. It automatically places the first selected
  17214. cell in the top left corner of the visible rectangle.
  17215.  
  17216. \ LUpdate
  17217. 26
  17218. Procedure LUpdate (theRgn: RgnHandle; lHandle: ListHandle);
  17219.  
  17220.     LUpdate should be called in response to an update event. TheRgn
  17221. should be set to the visRgn of the list’s port (for more details, see
  17222. the BeginUpdate procedure in the Window Manager chapter). It redraws
  17223. any visible cells in lHandle that intersect theRgn. It also redraws
  17224. the controls, if necessary.
  17225.  
  17226. \ LActivate
  17227. 26
  17228. Procedure LActivate (act: BOOLEAN; lHandle: ListHandle);
  17229.  
  17230.     Call LActivate to activate or deactivate the list specified by
  17231. lHandle (in response to an activate event in the window containing the
  17232. list). The act parameter should be set to TRUE to activate the list, or
  17233. FALSE to deactivate the list. LActivate highlights or unhighlights the
  17234. selections, and shows or hides the scroll bars (but not the size box, if
  17235. any).
  17236. \ Reset
  17237. 27
  17238. Procedure Reset( F, [,title] );
  17239.  
  17240.     F is a variable of type file; if title is given the file must not be open. If the title is not given, the file must be open. Title is expression with a string value.
  17241.     Reset(f) when f is already open causes f to be rewound. If f was open with rewrite then f becomes read-only. Reset(f, title) finds an existing file with name title an associate f to this file.
  17242.     After Reset, if the file is empty then Eof(f) is true and f^ undefined else Eof(f) is false and f^ contains the first component of the file.
  17243. \ Rewrite
  17244. 27
  17245. Procedure Rewrite( F, [,title] );
  17246.  
  17247.     F is a variable of type file; if title is given the file must not be open. If the title is not given, the file must be open. Title is expression with a string value.
  17248.  
  17249.    Rewrite(f) if f is not yet open, create an empty anonymous file. Rewrite(f) if f is already open, rewound the file to the beginning and empties it. If f was originally open with reset the file becoms write-only.
  17250.  
  17251.     Rewrite(f,title) creates a new empty file. If a file with this name already exists, it is deleted.
  17252.  
  17253. After Rewrite :
  17254.     - Eof(f) is true .
  17255.     - F^ is undefined .
  17256.  
  17257. \ Open
  17258. 27
  17259. Procedure Open (f, title);
  17260.  
  17261.     F is a variable of type file; f must not be already open. Title is expression with a string value. If no file with this name exists, a new empty file is created. The file F is opened for both reading and writing.
  17262.  
  17263. After Rewrite
  17264.    - Eof(f) is true if the file is empty.
  17265.    - f^ contains the first component if Eof(f) is false.
  17266. \ Close
  17267. 27
  17268. Procedure Close(f);
  17269.  
  17270.     F is a variable of type file; f must be open and must not be an anonymous file.
  17271.  
  17272. After Close, F^ becomes undefined.
  17273. \Eof
  17274. 27
  17275. Function EOF [(F)] :Boolean;
  17276.  
  17277.     F is a variable of type file; f must be open. If F is ommited f is the standard input file.
  17278.  
  17279.     Eof returns true if the file position is behind the last component of the file or if the file is empty.
  17280.  
  17281.     After a put Eof is true if the component written is now the last component of the file. So, on write-only files Eof is always true.
  17282. \ Get
  17283. 27
  17284. Procedure Get(f);
  17285.  
  17286.     F is a variable of type file; f must be open. Get advances the file position to the next component and assigns its vaalue to f^. If no next component exists the eof(f) becomes true.
  17287. \ Put
  17288. 27
  17289. Procedure Put(f);
  17290.  
  17291.     F is a variable of type file; f must be open.
  17292.  
  17293.     Put writes the value of F^ at the current file position and advances the file position to the next component. If no next component exists the eof(f) becomes true. F^ becomes undefined.
  17294. \ Seek
  17295. 27
  17296. Procedure Seek(f,n);
  17297.  
  17298.     F is a variable of type file; f must be open with an open call.
  17299. n is an integer specifying the new file position.
  17300.     After Seek F^ is the value on the nth component ( numbered from 0 ) unless Eof(f) is true ( when n is greater than the number of components in the file ).
  17301.  
  17302.    Warning: Seek on devices is not allowed.
  17303. \ FilePos
  17304. 27
  17305. Function FilePos(f):LongInt;
  17306.  
  17307.     F is a variable of type file; f must be open. FilePos returns the file component number of the the current file position.
  17308.  
  17309. \ Length
  17310. 28
  17311. Function Length(st:String):Integer;
  17312.  
  17313.     Returns the length of the string.
  17314.  
  17315. \ Pos
  17316. 28
  17317. Function Pos(SubStr,Str:String):Integer;
  17318.  
  17319.     Search for substr within str, and returns an integer value that is the index of the first character of substr withinin str. If substr is not found 0 is return.
  17320. \ Concat
  17321. 28
  17322. Function Concat(str1,str2 ...Strn:String):String;
  17323.  
  17324.     Concatenate all the parameters in the order in which they are written.
  17325. \ Copy
  17326. 28
  17327. Function Copy(s:string; index,count:integer):String;
  17328.  
  17329.    Returns a string containing count characters from s, beginning at     s[index]. If count≤0 then '' is returned. If count+index>Length(s) then only the last Length(s)-index+1 characters are copied.
  17330. \ Delete
  17331. 28
  17332. Procedure Delete(var s:string;index,count:integer);
  17333.  
  17334.     Remove all characters of s from s. only characters in the range 1..Length(s) are deleted.
  17335. \ Omit
  17336. 28
  17337. Function Omit(s:string; index,count:integer):String;
  17338.  
  17339.     Idem to delete but the destination is the function result instead of the source.
  17340. \ Insert
  17341. 28
  17342. Procedure insert( source : String; var Dest:String;index:integer);
  17343.  
  17344.     Inserts source into dest before the character specified by index. If index<=1 the source is inserted at the left of dest. If index>length(Dest) the source is inserted at the right of dest.
  17345. \ Globals By Name
  17346. 30
  17347. Global Variables sorted By Name:
  17348.  
  17349. ABusVars        $2D8    Pointer to AppleTalk variables
  17350. ACount          $A9A    Stage number (0-3) of last alert (Word)
  17351. ANumber         $A98    Resource ID of last alert (word)
  17352. ApFontID        $984    Font number of application font (word)
  17353. ApplLimit       $130    Application heap limit
  17354. ApplScratch     $A78    12-byte scratch area reserved for use by
  17355.                         applications
  17356. ApplZone        $2AA    Address of Application heap zone
  17357. AppParmHandle   $AEC    Handle to Finder information
  17358. AtMenuBottom    $B28    Flag for menu scrolling (word).
  17359. AuxCtlHead      $CD4    Auxiliary control list header (long).
  17360. AuxWinHead      $CD0    Auxiliary window list header (long).
  17361. BootDrive       $210    Working directory reference number for system
  17362.                         startup volume.
  17363. BufPtr          $10C    Address of end of jump table
  17364. BufTgDate       $304    File tags buffer: Date and time of last mod.
  17365.                         (long)
  17366. BufTgFBkNum     $302    File tags buffer: logical block number (word)
  17367. BufTgFFlg       $300    File tags buffer: flags (word: bit 1=1 if
  17368.                         resource fork)
  17369. BufTgFNum       $2FC    File tags buffer: file number (long)
  17370. CaretTime       $2F4    Caret-blink interval in ticks (long)
  17371. CPUFlag         $12F    Microprocessor in use
  17372. CrsrThresh      $8EC    Mouse-scaling threshold (word)
  17373. CurActivate     $A64    Pointer to window to receive activate event
  17374. CurApName       $910    Name of current application (string[31])
  17375. CurApRefNum     $900    Reference number of current applicatin's
  17376.                         resource file
  17377. CurDeactive     $A68    Pointer to window to receive deactivate event
  17378. CurDirStore     $398    Directory ID of directory last opened (long)
  17379. CurJTOffset     $934    Offset to jump table from location pointed
  17380.                         by A5 (word)
  17381. CurMap          $A5A    Reference number of current resource file (word)
  17382. CurPageOption   $936    Sound/Screen buffer configuration passed to
  17383.                         chain or launch (word)
  17384. CurPitch        $280    Value of count in square-wave synthetiser
  17385.                         buffer (word)
  17386. CurrentA5       $904    address of boundary between application globals
  17387.                         and application parameters
  17388. CurStackBase    $908    Address of base of stack; start of application
  17389.                         globals
  17390. DABeeper        $A9C    Address of current sound procedure
  17391. DAStrings       $AA0    Handle to ParamText strings (16 bytes)
  17392. DefltStack      $322    Default space allotment for stack (long)
  17393. DefVCBPtr       $352    Pointer to default volume control block
  17394. DeskHook        $A6C    Address of procedure for painting desktop or
  17395.                         responding to click on desktop
  17396. DeskPattern     $A3C    Pattern with which desktop is painted (8 bytes)
  17397. DlgFont         $AFA    Font number for dialogs and alerts (word)
  17398. DoubleTime      $2F0    double click interval in ticks (long)
  17399. DragHook        $9F6    Address of procedure to execute during
  17400.                         TrackGoAway, DragWindow, GrowWindow, DragGrayRg,
  17401.                         TrackControl, and DragControl.
  17402. DragPattern     $A34    Pattern of dragged region's outline
  17403. DrvQHdr         $308    Drive queue header (10 bytes)
  17404. DSAlertRect     $3F8    Rectangle enclosing system error alert (8 bytes)
  17405. DSAlertTab      $2BA    Pointer to system error alert table in use
  17406. DSErrCode       $AF0    Current system error ID (word)
  17407. DTQueue         $D92    Deferred task queue header (10 bytes).
  17408. EventQueue      $14A    Event queue header (10 bytes)
  17409. ExtStsDT        $2BE    External/status interrupt vector table(16 bytes)
  17410. FCBSPtr         $34E    Pointer to file-control-block buffer
  17411. FinderName      $2E0    Name of the Finder (String [15])
  17412. FractEnable     $BF4    Nonzero to enable fractional widths (byte)
  17413. FScaleDisable   $A63    Nonzero to disable font scaling (byte)
  17414. FSFCBLen        $3F6    Size of a file control block; on 64K ROM, it
  17415.                         contains -1(word).
  17416. FSQHdr          $360    File I/O queue header (10 bytes)
  17417. GhostWindow     $A84    Pointer to window never to be considered
  17418.                         frontmost
  17419. GrayRgn         $9EE    Handle to region drawn as desktop
  17420. GZRootHnd       $328    Handle to relocatable block not to be moved by
  17421.                         GrowZone function
  17422. HeapEnd         $114    Address end of applicatio heap zone
  17423. HWCfgFlags      $B22    Hardware configuration information (word).
  17424. IntlSpec        $BA0    International software installed if not equal
  17425.                         to -1 (long).
  17426. JADBProc        $6B8    Pointer to ADBReInit preprocessing/
  17427.                         postprocessing routine.
  17428. JDTInstall      $D9C    Jump vector for DTInstall routine.
  17429. JFetch          $8F4    Jump vector to Fetch function
  17430. JIODone         $8FC    Jump vector for IODne function
  17431. JournalFlag     $8DE    journaling mode (word)
  17432. JStash          $8F8    Jump vector for stash function
  17433. JVBLTask        $D28    Jump vector for DoVBLTask
  17434. KbdLast         $218    ADB address of the keyboard last used (byte).
  17435. KbdType         $21E    Keyboard type of the keyboard last used (byte).
  17436. KeyRepThresh    $190    Auto-key rate (word)
  17437. KeyThresh       $18E    Auto-key threshold (word)
  17438. LastFOND        $BC2    Handle to last family record used
  17439. LO3Bytes        $31A    $00FFFFFF
  17440. Lvl1DT          $192    Level-1 secondary interrupt vector
  17441.                         table (32 bytes)
  17442. Lvl2DT          $1B2    Level-2 secondary interrupt vector table
  17443.                         (32 bytes)
  17444. MBarEnable      $A20    Unique menu ID for active Desk-Accessory, when
  17445.                         menu bar belongs to the accessory
  17446. MBarHeight      $BAA    Height of menu bar (word).
  17447. MBarHook        $A2C    address of routine called by MenuSelect before
  17448.                         menu is drawn.
  17449. MBSaveLoc       $B58    Location of menu bar
  17450. MemErr          $220    Current value of MemError (word)
  17451. MemTop          $108    Address of end of RAM (on Macintosh XL, end of
  17452.                         RAM available to appls.)
  17453. MenuCInfo       $D5C    Header for menu color information table.
  17454. MenuDisable     $B54    Menu ID and item for selected disabled item.
  17455. MenuFlash       $A24    Count for duration of menu item blinking (word).
  17456. MenuList        $A1C    Handle to current menu list.
  17457. MinStack        $31E    Minimum space allotment for stack (long)
  17458. MinusOne        $A06    $FFFFFFFF
  17459. MMU32Bit        $14B2   Current address mode (byte).
  17460. OldContent      $9EA    Handle to saved content region.
  17461. OldStructure    $9E6    Handle to saved structure region.
  17462. OneOne          $A02    $00010001
  17463. PaintWhite      $9DC    Flag for wether to paint window white before
  17464.                         update event (word).
  17465. PortBUse        $291    Current availability of serial port B (byte).
  17466. PrintErr        $944    Result code from last Printing Manager routine
  17467.                         (word).
  17468. RAMBase         $2B2    Trap dispatch table's base address for routines in RAM.
  17469. ResErr          $A60    Current value of ResError (word).
  17470. ResErrProc      $AF2    Address of resource error procedure.
  17471. ResLoad         $A5E    Current SetResLoad state (word).
  17472. ResumeProc      $A8C    Address of resume procedure.
  17473. RndSeed         $156    Random number seed (long).
  17474. ROM85           $28E    Version number of ROM (word).
  17475. ROMBase         $2AE    Base address of ROM.
  17476. RomFont0        $980    Handle to font record for system font.
  17477. RomMapInsert    $B9E    Flag for wether to insert map to the ROM
  17478.                         resources (byte)
  17479. SaveUpdate      $9DA    Flag for wether to generate update events (word).
  17480. SaveVisRgn      $9F2    Handle to saved VisRgn.
  17481. SCCRd           $1D8    SCC Read base address.
  17482. SCCWr           $1DC    SCC Write base address.
  17483. ScrapCount      $968    Count changed by ZeroScrap (word).
  17484. ScrapHandle     $964    Handle to desk scrap in memory.
  17485. ScrapName       $96C    Pointer to scrap file name (preceded by length
  17486.                         byte).
  17487. ScrapSize       $960    Size in bytes of desk scrap (long).
  17488. ScrapState      $96A    Tells where desk scrap is (word).
  17489. Scratch20       $1E4    20-bytes scratch area
  17490. Scratch8        $9FA    8-bytes scratch area
  17491. ScrDmpEnb       $2F8    0 if GetNextEvent should process
  17492.                         Command-shift-number combinations (byte).
  17493. ScrHRes         $104    Pixels per inch horizontally (word).
  17494. ScrnBase        $824    Address of main screen buffer.
  17495. ScrVRes         $102    Pixels per inch vertically (word).
  17496. SdVolume        $260    Current speaker volume (byte: low-order three
  17497.                         bits only).
  17498. SEvtEnb         $15C    0 if SystemEvent should return False (byte).
  17499. SFSaveDisk      $214    Negative of volume reference number, used by
  17500.                         Standard File Package (word)
  17501. SoundBase       $266    Pointer to free-form synthetizer buffer.
  17502. SoundLevel      $27F    Amplitude in 740-byte buffer (byte).
  17503. SoundPtr        $262    Pointer to four-tone record
  17504. SPAlarm         $200    Alarm setting (long).
  17505. SPATalkA        $1F9    AppleTalk node ID hint for Modem port (byte).
  17506. SPATalkB        $1FA    AppleTalk node ID hint for printer port (byte).
  17507. SPClickCaret    $209    Double-click and caret-blink times (byte).
  17508. SPConfig        $1FB    Use types for serial ports (byte).
  17509. SPFont          $204    Application font number minus 1 (word).
  17510. SPKbd           $206    Auto-key threshold and rate (byte).
  17511. SPMisc2         $20B    Mouse scaling, system startup disk,
  17512.                         menu blink (byte).
  17513. SPPortA         $1FC    Modem port configuration (word).
  17514. SPPortB         $1FE    Printer port configuration (word).
  17515. SPPrint         $207    Printer connection (byte).
  17516. SPValid         $1F8    Validity status (byte).
  17517. SPVolCtl        $208    Speaker volume setting in parameter RAM (byte).
  17518. SysEvtMask      $144    System Event Mask (word).
  17519. SysFontRam      $BA6    If nonzero, the font number to use for system
  17520.                         font (word).
  17521. SysFontSize     $BA8    If nonzero, the size of the System Font (word).
  17522. SysMap          $A58    Reference number of system resiurce file (word).
  17523. SysMapHndl      $A54    Handle to map of system resource file (word).
  17524. SysParam        $1F8    Low-memory copy of parameter RAM (20 bytes).
  17525. SysResName      $AD8    Name of system resource file (length followed by
  17526.                         up to 19 chars).
  17527. SysZone         $2A6    Address of system heap zone.
  17528. TEDoText        $A70    Address of TextEdit multi-purpose routine.
  17529. TERecal         $A74    Address of routine toi recalculate line starts
  17530.                         for TextEdit.
  17531. TEScrpHandle    $AB4    Handle to TextEditScrap.
  17532. TEScrpLength    $AB0    Size in bytes of TextEdit Scrap (long)
  17533. TheMenu         $A26    Menu ID of current highlited menu (word).
  17534. TheZone         $118    Address of current heap zone
  17535. Ticks           $16A    Current number of ticks since system
  17536.                         startup (long)
  17537. Time            $20C    Seconds since midnight, January 1, 1904 (long)
  17538. TimeDBRA        $D00    Number of times the DBRA instruction can be
  17539.                         executed per millisecond (word).
  17540. TmpResLoad      $B9F    Temporary SetResLoad state for calls using
  17541.                         RomMapInsert (byte).
  17542. ToExtFS         $3F2    Pointer to external file system.
  17543. ToolScratch     $9CE    8-byte scratch area.
  17544. TopMapHndl      $A50    Handle to resource map of most recently opened
  17545.                         resource file.
  17546. TopMenuItem     $B26    (word).
  17547. UTableBase      $11C    Base Address of unit table.
  17548. VBLQueue        $160    Vertical retrace queue header (10 bytes).
  17549. VCBQHdr         $356    Volume-control-block queue header (10 bytes)
  17550. VIA             $1DA    VIA base address.
  17551. WidthListHand   $8E4    Handle to a list of handles to recently-used
  17552.                         width tables.
  17553. WidthPtr        $B10    Pointer to global width table
  17554. WidthTabHandle  $B2A    Handle to global width table.
  17555. WindowList      $9D6    Pointer to first window in window list; 0 if
  17556.                         using events but not windows.
  17557. WMgrPort        $9DE    Pointer to window manager port.
  17558. \ Globals by Address
  17559. 30
  17560. Global Variables sorted by Address:
  17561.  
  17562. ScrVRes         $102    Pixels per inch vertically (word).
  17563. ScrHRes         $104    Pixels per inch horizontally (word).
  17564. MemTop          $108    Address of end of RAM (on Macintosh XL, end of
  17565.                         RAM available to appls.)
  17566. BufPtr          $10C    Address of end of jump table
  17567. HeapEnd         $114    Address end of applicatio heap zone
  17568. TheZone         $118    Address of current heap zone
  17569. UTableBase      $11C    Base Address of unit table.
  17570. CPUFlag         $12F    Microprocessor in use
  17571. ApplLimit       $130    Application heap limit
  17572. SysEvtMask      $144    System Event Mask (word).
  17573. EventQueue      $14A    Event queue header (10 bytes)
  17574. RndSeed         $156    Random number seed (long).
  17575. SEvtEnb         $15C    0 if SystemEvent should return False (byte).
  17576. VBLQueue        $160    Vertical retrace queue header (10 bytes).
  17577. Ticks           $16A    Current number of ticks since system
  17578.                         startup (long)
  17579. KeyThresh       $18E    Auto-key threshold (word)
  17580. KeyRepThresh    $190    Auto-key rate (word)
  17581. Lvl1DT          $192    Level-1 secondary Int vector table (32 bytes)
  17582. Lvl2DT          $1B2    Level-2 secondary Int. vector table (32 bytes)
  17583. SCCRd           $1D8    SCC Read base address.
  17584. VIA             $1DA    VIA base address.
  17585. SCCWr           $1DC    SCC Write base address.
  17586. Scratch20       $1E4    20-bytes scratch area
  17587. SPValid         $1F8    Validity status (byte).
  17588. SysParam        $1F8    Low-memory copy of parameter RAM (20 bytes).
  17589. SPATalkA        $1F9    AppleTalk node ID hint for Modem port (byte).
  17590. SPATalkB        $1FA    AppleTalk node ID hint for printer port (byte).
  17591. SPConfig        $1FB    Use types for serial ports (byte).
  17592. SPPortA         $1FC    Modem port configuration (word).
  17593. SPPortB         $1FE    Printer port configuration (word).
  17594. SPAlarm         $200    Alarm setting (long).
  17595. SPFont          $204    Application font number minus 1 (word).
  17596. SPKbd           $206    Auto-key threshold and rate (byte).
  17597. SPPrint         $207    Printer connection (byte).
  17598. SPVolCtl        $208    Speaker volume setting in parameter RAM (byte).
  17599. SPClickCaret    $209    Double-click and caret-blink times (byte).
  17600. SPMisc2         $20B    Mouse scaling, system startup disk,
  17601.                         menu blink(byte).
  17602. Time            $20C    Seconds since midnight, January 1, 1904 (long)
  17603. BootDrive       $210    Working directory reference number for system
  17604.                         startup volume.
  17605. SFSaveDisk      $214    Negative of volume reference number, used by
  17606.                         Standard File Package (word)
  17607. KbdLast         $218    ADB address of the keyboard last used (byte).
  17608. KbdType         $21E    Keyboard type of the keyboard last used (byte).
  17609. MemErr          $220    Current value of MemError (word)
  17610. SdVolume        $260    Current speaker volume (byte: low-order
  17611.                         three bits only).
  17612. SoundPtr        $262    Pointer to four-tone record
  17613. SoundBase       $266    Pointer to free-form synthetizer buffer.
  17614. SoundLevel      $27F    Amplitude in 740-byte buffer (byte).
  17615. CurPitch        $280    Value of count in square-wave synthetiser
  17616.                         buffer (word)
  17617. ROM85           $28E    Version number of ROM (word).
  17618. PortBUse        $291    Current availability of serial port B (byte).
  17619. SysZone         $2A6    Address of system heap zone.
  17620. ApplZone        $2AA    Address of Application heap zone
  17621. ROMBase         $2AE    Base address of ROM.
  17622. RAMBase         $2B2    Trap dispatch table's base address for routines                          in RAM.
  17623. DSAlertTab      $2BA    Pointer to system error alert table in use
  17624. ExtStsDT        $2BE    External/status interrupt vector table(16 bytes)
  17625. ABusVars        $2D8    Pointer to AppleTalk variables
  17626. FinderName      $2E0    Name of the Finder (String [15])
  17627. DoubleTime      $2F0    double click interval in ticks (long)
  17628. CaretTime       $2F4    Caret-blink interval in ticks (long)
  17629. ScrDmpEnb       $2F8    0 if GetNextEvent should process
  17630.                         Command-shift-number combinations (byte).
  17631. BufTgFNum       $2FC    File tags buffer: file number (long)
  17632. BufTgFFlg       $300    File tags buffer: flags (word: bit 1=1 if
  17633.                         resource fork)
  17634. BufTgFBkNum     $302    File tags buffer: logical block number (word)
  17635. BufTgDate       $304    File tags buffer: Date and time of last mod.
  17636.                         (long)
  17637. DrvQHdr         $308    Drive queue header (10 bytes)
  17638. LO3Bytes        $31A    $00FFFFFF
  17639. MinStack        $31E    Minimum space allotment for stack (long)
  17640. DefltStack      $322    Default space allotment for stack (long)
  17641. GZRootHnd       $328    Handle to relocatable block not to be moved
  17642.                         by GrowZone function
  17643. FCBSPtr         $34E    Pointer to file-control-block buffer
  17644. DefVCBPtr       $352    Pointer to default volume control block
  17645. VCBQHdr         $356    Volume-control-block queue header (10 bytes)
  17646. FSQHdr          $360    File I/O queue header (10 bytes)
  17647. CurDirStore     $398    Directory ID of directory last opened (long)
  17648. ToExtFS         $3F2    Pointer to external file system.
  17649. FSFCBLen        $3F6    Size of a file control block; on 64K ROM,
  17650.                         it contains -1(word).
  17651. DSAlertRect     $3F8    Rectangle enclosing system error alert(8 bytes)
  17652. JADBProc        $6B8    Pointer to ADBReInit preprocessing/
  17653.                         postprocessing routine.
  17654. ScrnBase        $824    Address of main screen buffer.
  17655. JournalFlag     $8DE    journaling mode (word)
  17656. WidthListHand   $8E4    Handle to a list of handles to recently-used
  17657.                         width tables.
  17658. CrsrThresh      $8EC    Mouse-scaling threshold (word)
  17659. JFetch          $8F4    Jump vector to Fetch function
  17660. JStash          $8F8    Jump vector for stash function
  17661. JIODone         $8FC    Jump vector for IODne function
  17662. CurApRefNum     $900    Reference number of current applicatin's
  17663.                         resource file
  17664. CurrentA5       $904    address of boundary between application globals
  17665.                         and application parameters
  17666. CurStackBase    $908    Address of base of stack; start of application
  17667.                         globals
  17668. CurApName       $910    Name of current application (string[31])
  17669. CurJTOffset     $934    Offset to jump table from location pointed by
  17670.                         A5 (word)
  17671. CurPageOption   $936    Sound/Screen buffer configuration passed to
  17672.                         chain or launch (word)
  17673. PrintErr        $944    Result code from last Printing Manager routine
  17674.                         (word).
  17675. ScrapSize       $960    Size in bytes of desk scrap (long).
  17676. ScrapHandle     $964    Handle to desk scrap in memory.
  17677. ScrapCount      $968    Count changed by ZeroScrap (word).
  17678. ScrapState      $96A    Tells where desk scrap is (word).
  17679. ScrapName       $96C    Pointer to scrap file name (preceded by
  17680.                         length byte).
  17681. RomFont0        $980    Handle to font record for system font.
  17682. ApFontID        $984    Font number of application font (word)
  17683. ToolScratch     $9CE    8-byte scratch area.
  17684. WindowList      $9D6    Pointer to first window in window list; 0 if
  17685.                         using events but not windows.
  17686. SaveUpdate      $9DA    Flag for wether to generate update events(word).
  17687. PaintWhite      $9DC    Flag for wether to paint window white before
  17688.                         update event (word).
  17689. WMgrPort        $9DE    Pointer to window manager port.
  17690. OldStructure    $9E6    Handle to saved structure region.
  17691. OldContent      $9EA    Handle to saved content region.
  17692. GrayRgn         $9EE    Handle to region drawn as desktop
  17693. SaveVisRgn      $9F2    Handle to saved VisRgn.
  17694. DragHook        $9F6    address of procedure to execute during
  17695.                         TrackGoAway, DragWindow, GrowWindow, DragGrayRg,
  17696.                         TrackControl, and DragControl
  17697. Scratch8        $9FA    8-bytes scratch area
  17698. OneOne          $A02    $00010001
  17699. MinusOne        $A06    $FFFFFFFF
  17700. MenuList        $A1C    Handle to current menu list.
  17701. MBarEnable      $A20    Unique menu ID for active Desk-Accessory, when
  17702.                         menu bar belongs to the accessory
  17703. MenuFlash       $A24    Count for duration of menu item blinking (word).
  17704. TheMenu         $A26    Menu ID of current highlited menu (word).
  17705. MBarHook        $A2C    address of routine called by MenuSelect before
  17706.                         menu is drawn.
  17707. DragPattern     $A34    Pattern of dragged region's outline
  17708. DeskPattern     $A3C    Pattern with which desktop is painted (8 bytes)
  17709. TopMapHndl      $A50    Handle to resource map of most recently opened
  17710.                         resource file.
  17711. SysMapHndl      $A54    Handle to map of system resource file (word).
  17712. SysMap          $A58    Reference number of system resiurce file (word)
  17713. CurMap          $A5A    Reference number of current resource file (word)
  17714. ResLoad         $A5E    Current SetResLoad state (word).
  17715. ResErr          $A60    Current value of ResError (word).
  17716. FScaleDisable   $A63    Nonzero to disable font scaling (byte)
  17717. CurActivate     $A64    Pointer to window to receive activate event
  17718. CurDeactive     $A68    Pointer to window to receive deactivate event
  17719. DeskHook        $A6C    Address of procedure for painting desktop or
  17720.                         responding to click on desktop
  17721. TEDoText        $A70    Address of TextEdit multi-purpose routine.
  17722. TERecal         $A74    Address of routine toi recalculate line starts
  17723.                         for TextEdit.
  17724. ApplScratch     $A78    12-byte scratch area reserved for use by
  17725.                         applications
  17726. GhostWindow     $A84    Pointer to window never to be considered
  17727.                         frontmost
  17728. ResumeProc      $A8C    Address of resume procedure.
  17729. ANumber         $A98    Resource ID of last alert (word)
  17730. ACount          $A9A    Stage number (0-3) of last alert (Word)
  17731. DABeeper        $A9C    Address of current sound procedure
  17732. DAStrings       $AA0    Handle to ParamText strings (16 bytes)
  17733. TEScrpLength    $AB0    Size in bytes of TextEdit Scrap (long)
  17734. TEScrpHandle    $AB4    Handle to TextEditScrap.
  17735. SysResName      $AD8    Name of system resource file (length followed
  17736.                         by up to 19 chars).
  17737. AppParmHandle   $AEC    Handle to Finder information
  17738. DSErrCode       $AF0    Current system error ID (word)
  17739. ResErrProc      $AF2    Address of resource error procedure.
  17740. DlgFont         $AFA    Font number for dialogs and alerts (word)
  17741. WidthPtr        $B10    Pointer to global width table
  17742. HWCfgFlags      $B22    Hardware configuration information (word).
  17743. TopMenuItem     $B26    (word).
  17744. AtMenuBottom    $B28    Flag for menu scrolling (word).
  17745. WidthTabHandle  $B2A    Handle to global width table.
  17746. MenuDisable     $B54    Menu ID and item for selected disabled item.
  17747. MBSaveLoc       $B58    Location of menu bar
  17748. RomMapInsert    $B9E    Flag for wether to insert map to the ROM
  17749.                         resources (byte)
  17750. TmpResLoad      $B9F    Temporary SetResLoad state for calls using
  17751.                         RomMapInsert (byte).
  17752. IntlSpec        $BA0    International software installed if not equal
  17753.                         to -1 (long).
  17754. SysFontRam      $BA6    If nonzero, the font number to use for system
  17755.                         font (word).
  17756. SysFontSize     $BA8    If nonzero, the size of the System Font (word).
  17757. MBarHeight      $BAA    Height of menu bar (word).
  17758. LastFOND        $BC2    Handle to last family record used
  17759. FractEnable     $BF4    Nonzero to enable fractional widths (byte)
  17760. AuxWinHead      $CD0    Auxiliary window list header (long).
  17761. AuxCtlHead      $CD4    Auxiliary control list header (long).
  17762. TimeDBRA        $D00    Number of times the DBRA instruction can be
  17763.                         executed per millisecond (word).
  17764. JVBLTask        $D28    Jump vector for DoVBLTask
  17765. MenuCInfo       $D5C    Header for menu color information table.
  17766. DTQueue         $D92    Deferred task queue header (10 bytes).
  17767. JDTInstall      $D9C    Jump vector for DTInstall routine.
  17768. MMU32Bit        $14B2   Current address mode (byte).
  17769. \ Error code
  17770. 30
  17771. General System Errors (VBL Mgr, Queueing, Etc.)
  17772.  
  17773. noErr           0       0 for success
  17774. qErr            -1      queue element not found during deletion
  17775. vTypErr         -2      invalid queue element
  17776. corErr          -3      core routine number out of range
  17777. unimpErr        -4      unimplemented core routine
  17778. SENoDB          -8      no debugger installed to handle debugger command
  17779.  
  17780. I/O System Errors
  17781.  
  17782. controlErr      -17
  17783. statusErr       -18
  17784. readErr         -19
  17785. writErr         -20
  17786. badUnitErr      -21
  17787. unitEmptyErr    -22
  17788. openErr         -23
  17789. closErr         -24
  17790. dRemovErr       -25     tried to remove an open driver
  17791. dInstErr        -26     DrvrInstall couldn't find driver in resources
  17792. abortErr        -27     IO call aborted by KillIO
  17793. notOpenErr      -28     Couldn't rd/wr/ctl/sts cause driver not opened
  17794.  
  17795. File System error codes
  17796.  
  17797. dirFulErr       -33     Directory full
  17798. dskFulErr       -34     disk full
  17799. nsvErr          -35     no such volume
  17800. ioErr           -36     I/O error (bummers)
  17801. bdNamErr        -37     there may be no bad names in the final system!
  17802. fnOpnErr        -38     File not open
  17803. eofErr          -39     End of file
  17804. posErr          -40     tried to position to before start of file (r/w)
  17805. mFulErr         -41     memory full (open) or file won't fit (load)
  17806. tmfoErr         -42     too many files open
  17807. fnfErr          -43     File not found
  17808.  
  17809. wPrErr          -44     diskette is write protected
  17810. fLckdErr        -45     file is locked
  17811. vLckdErr        -46     volume is locked
  17812. fBsyErr         -47     File is busy (delete)
  17813. dupFNErr        -48     duplicate filename (rename)
  17814. opWrErr         -49     file already open with with write permission
  17815. paramErr        -50     error in user parameter list
  17816. rfNumErr        -51     refnum error
  17817. gfpErr          -52     get file position error
  17818. volOffLinErr    -53     volume not on line error (was Ejected)
  17819. permErr         -54     permissions error (on file open)
  17820. volOnLinErr     -55     drive volume already on-line at MountVol
  17821. nsDrvErr        -56     no such drive (tried to mount a bad drive num)
  17822. noMacDskErr     -57     not a mac diskette (sig bytes are wrong)
  17823. extFSErr        -58     volume in question belongs to an external fs
  17824. fsRnErr         -59     file system internal error: during rename the
  17825.    old entry was deleted but could not be restored
  17826. badMDBErr       -60     bad master directory block
  17827. wrPermErr       -61     write permissions error
  17828.  
  17829. Font Manager Error Codes
  17830.  
  17831. fontDecError    -64     error during font declaration
  17832. fontNotDeclared -65
  17833. fontSubErr      -66     font substitution occured
  17834.  
  17835. Disk, Serial Ports, Clock Specific Errors
  17836.  
  17837. firstDskErr     -84
  17838. lastDskErr      -64
  17839.  
  17840. noDriveErr      -64     drive not installed
  17841. offLinErr       -65     r/w requested for an off-line drive
  17842.  
  17843. noNybErr        -66     couldn't find 5 nybbles in 200 tries
  17844. noAdrMkErr      -67     couldn't find valid addr mark
  17845. dataVerErr      -68     read verify compare failed
  17846. badCkSmErr      -69     addr mark checksum didn't check
  17847. badBtSlpErr     -70     bad addr mark bit slip nibbles
  17848. noDtaMkErr      -71     couldn't find a data mark header
  17849. badDCkSum       -72     bad data mark checksum
  17850. badDBtSlp       -73     bad data mark bit slip nibbles
  17851. wrUnderRun      -74     write underrun occurred
  17852.  
  17853. cantStepErr     -75     step handshake failed
  17854. tk0BadErr       -76     track 0 detect doesn't change
  17855. initIWMErr      -77     unable to initialize IWM
  17856. twoSideErr      -78     tried to read 2nd side on a 1-sided drive
  17857. spdAdjErr       -79     unable to correctly adjust disk speed
  17858. seekErr         -80     track number wrong on address mark
  17859. sectNFErr       -81     sector number never found on a track
  17860.  
  17861. Fmt1Err         -82     can't find sector 0 after track format
  17862. Fmt2Err         -83     can't get enough sync
  17863. VerErr          -84     track failed to verify
  17864.  
  17865.  
  17866. clkRdErr        -85     unable to read same clock value twice
  17867. clkWrErr        -86     time written did not verify
  17868. prWrErr         -87     parameter ram written didn't read-verify
  17869. prInitErr       -88     InitUtil found the parameter ram uninitialized
  17870.  
  17871. rcvrErr         -89     SCC receiver error (framing, parity, OR)
  17872. breakRecd       -90     Break received (SCC)
  17873.  
  17874. AppleTalk error codes
  17875.  
  17876. ddpSktErr       -91     error in soket number
  17877. ddpLenErr       -92     data length too big
  17878. noBridgeErr     -93     no network bridge for non-local send
  17879. lapProtErr      -94     error in attaching/detaching protocol
  17880. excessCollsns   -95     excessive collisions on write
  17881. portInUse       -97     driver Open error code (port is in use)
  17882. portNotCf       -98     driver Open error code (parameter RAM not
  17883.    configured for this connection)
  17884. memROZErr       -99     hard error in ROZ
  17885.  
  17886. Scrap Manager error codes
  17887.  
  17888. noScrapErr      -100    No scrap exists error
  17889. noTypeErr       -102    No object of that type in scrap
  17890.  
  17891. Storage allocator error codes
  17892.  
  17893. memFullErr      -108    Not enough room in heap zone
  17894. nilHandleErr    -109    Handle was NIL in HandleZone or other
  17895. memWZErr        -111    WhichZone failed (applied to free block)
  17896. memPurErr       -112    trying to purge a locked or non-purgeable block
  17897.  
  17898. memAdrErr       -110    address was odd, or out of range
  17899. memAZErr        -113    Address in zone check failed
  17900. memPCErr        -114    Pointer Check failed
  17901. memBCErr        -115    Block Check failed
  17902. memSCErr        -116    Size Check failed
  17903. memLockedErr    -117    trying to move a locked block (MoveHHi)
  17904.  
  17905. New system error codes
  17906.  
  17907. dirNFErr        -120    Directory not found
  17908. tMWDOErr        -121    No free WDCB available
  17909. badMovErr       -122    Move into offspring error
  17910. wrgVolTypErr    -123    Wrong volume type error [operation not supported
  17911.    for MFS]
  17912.  
  17913. Resource Manager error codes (other than I/O errors)
  17914.  
  17915. resNotFound     -192    Resource not found
  17916. resFNotFound    -193    Resource file not found
  17917. addResFailed    -194    AddResource failed
  17918. addRefFailed    -195    AddReference failed
  17919. rmvResFailed    -196    RmveResource failed
  17920. rmvRefFailed    -197    RmveReference failed
  17921. resAttrErr      -198    attribute inconsistent with operation
  17922. mapReadErr      -199    map inconsistent with operation
  17923.  
  17924. AppleTalk - NBP error codes
  17925.  
  17926. nbpBuffOvr      -1024   Buffer overflow in LookupName
  17927. nbpNoConfirm    -1025   Name not confirmed on ConfirmName
  17928. nbpConfDiff     -1026   Name confirmed at different socket
  17929. nbpDuplicate    -1027   Duplicate name exists already
  17930. nbpNotFound     -1028   Name not found on remove
  17931. nbpNISErr       -1029   Error trying to open the NIS
  17932.  
  17933. AppleTalk -  ATP error codes
  17934.  
  17935. ReqFailed       -1096   SendRequest failed: retry count exceeded
  17936. TooManyReqs     -1097   Too many concurrent requests
  17937. TooManySkts     -1098   Too many concurrent responding-sockets
  17938. BadATPSkt       -1099   Bad ATP-responding socket
  17939. BadBuffNum      -1100   Bad response buffer number specififed
  17940. NoRelErr        -1101   No release received
  17941. CBNotFound      -1102   Control Block (TCB or RspCB) not found
  17942. NoSendResp      -1103   AddResponse issued without SendResponse
  17943. NoDataArea      -1104   No data area for request to MPP
  17944. ReqAborted      -1105   SendRequest aborted by RelTCB
  17945.  
  17946. Some miscellaneous result codes
  17947.  
  17948. evtNotEnb       1       event not enabled at PostEvent
  17949.  
  17950. System Error Alert ID definitions.  These are just for reference because
  17951. one cannot intercept the calls and do anything programmatically...
  17952.  
  17953. dsSysErr        32767   general system error
  17954. dsBusError      1       bus error
  17955. dsAddressErr    2       address error
  17956. dsIllInstErr    3       illegal instruction error
  17957. dsZeroDivErr    4       zero divide error
  17958. dsChkErr        5       check trap error
  17959. dsOvFlowErr     6       overflow trap error
  17960. dsPrivErr       7       privelege violation error
  17961. dsTraceErr      8       trace mode error
  17962. dsLineAErr      9       line 1010 trap error
  17963. dsLineFErr      10      line 1111 trap error
  17964. dsMiscErr       11      miscellaneous hardware exception error
  17965. dsCoreErr       12      unimplemented core routine error
  17966. dsIrqErr        13      uninstalled interrupt error
  17967.  
  17968. dsIOCoreErr     14      IO Core Error
  17969. dsLoadErr       15      Segment Loader Error
  17970. dsFPErr         16      Floating point error
  17971.  
  17972. dsNoPackErr     17      package 0 not present
  17973. dsNoPk1         18      package 1 not present
  17974. dsNoPk2         19      package 2 not present
  17975. dsNoPk3         20      package 3 not present
  17976. dsNoPk4         21      package 4 not present
  17977. dsNoPk5         22      package 5 not present
  17978. dsNoPk6         23      package 6 not present
  17979. dsNoPk7         24      package 7 not present
  17980.  
  17981. dsMemFullErr    25      out of memory!
  17982. dsBadLaunch     26      can't launch file
  17983. dsFSErr         27      file system map has been trashed
  17984. dsStknHeap      28      stack has moved into application heap
  17985. dsReinsert      30      request user to reinsert off-line volume
  17986. dsNotThe1       31      not the disk I wanted
  17987. negZcbFreeErr   33      ZcbFree has gone negative
  17988. menuPrgErr      84      happens when a menu is purged
  17989. \ OpenCPort
  17990. 2
  17991. Procedure OpenCPort (port: CGrafPtr);
  17992.  
  17993.     The OpenCPort procedure is analogous to OpenPort, except it opens a cGrafPort instead of a grafPort. You will rarely need to use this call, since OpenCPort is called by NewCWindow and GetNewCWindow, as well as by the Dialog Manager when the appropriate color resources are present.  OpenCPort allocates storage for all the structures in the cGrafPort, and then calls InitCPort to initialize them.  The new structures allocated are the portPixMap, the pnPixPat, the fillPixPat, the bkPixPat, and the grafVars handle.  The GrafVars record structure is shown below:
  17994.  
  17995. TYPE
  17996. GrafVars = RECORD
  17997.     rgbOpColor: RGBColor;       {color for addPin, subPin, and blend}
  17998.     rgbHiliteColor: RGBColor;   {color for highlighting}
  17999.     pmFgColor:  Handle;         {Palette handle for foreground color}
  18000.     pmFgIndex:  INTEGER;        {index value for foreground}
  18001.     pmBkColor:  Handle;         {Palette handle for background color}
  18002.     pmBkIndex:  INTEGER;        {index value for background}
  18003.     pmFlags:    INTEGER;        {Flags for Palette Manager}
  18004.     END;
  18005.  
  18006.     The rgbOpColor field is initialized as black, and the rgbHiliteColor field is initialized as the default HiliteRGB. All the rest of the GrafVars fields are initially zero.
  18007.  
  18008.     The portPixMap is not allocated a color table of its own. When InitCPort is called, the handle to the current device’s color table is copied into the portPixMap.
  18009. \ InitCPort
  18010. 2
  18011. Procedure InitCPort (port: CGrafPtr);
  18012.  
  18013.     The InitCPort procedure does not allocate any storage. It merely initializes all the fields in the cGrafPort to their default values.  All old fields are initialized to the same values as a grafPort’s fields. New fields are given the following values:
  18014.  
  18015. portPixMap:     copied from theGDevice^^.GDPMap
  18016. portVersion:    $C000
  18017. grafVars:       opColor initialized to black, rgbHiliteColor initialized
  18018.                 as default HiliteRGB. All other fields are initialized
  18019.                 as 0.
  18020. chExtra:        0
  18021. pnLocHFrac:     1/2
  18022. bkPixPat:       white
  18023. rgbFgColor:     black
  18024. rgbBkColor:     white
  18025. pnPixPat:       black
  18026. fillPixPat:     black
  18027.  
  18028.     The default portPixMap is set to be the same as the current device’s pixMap. This allows you to create an offscreen port that is identical to the screen’s grafPort or cGrafPort for drawing offscreen. If you want to use a different set of colors for offscreen drawing, you should create a new gDevice, and set it as the current gDevice before opening the cGrafPort. Refer to the section on offscreen bitMaps in the Graphics Devices chapter for more details.
  18029.     As mentioned above, InitCPort does not copy the data from the current device’s color table to the portPixMap’s color table. It simply replaces whatever is in the pmTable field with a copy of the handle to the current device’s color table.
  18030.     If you try to initialize a grafPort using InitCPort, it will simply return without doing anything.
  18031. \ CloseCPort
  18032. 2
  18033. Procedure CloseCPort (port: CGrafPtr);
  18034.  
  18035.     CloseCPort releases the memory allocated to the cGrafPort. It disposes of the visRgn, the clipRgn, the bkPixPat, the pnPixPat, the fillPixPat, and the grafVars handle. It also disposes of the portPixMap, but doesn’t dispose of the portPixMap’s color table (which is really owned by the gDevice). If you have placed your own color table into the portPixMap, either dispose of it before calling CloseCPort, or store another reference to it for other uses.
  18036. \ RGBForeColor
  18037. 2
  18038. Procedure RGBForeColor (color : RGBColor);
  18039.  
  18040.     These two calls set the foreground and background colors to the best available match for the current device. The only drawing operations that aren’t affected by these colors are PlotCIcon, and drawing using the new color patterns. Before you call CopyBits with a pixMap as the source, you should set the foreground to black and the background to white.
  18041.     If the current port is a cGrafPort, the specified RGB is placed in the rgbFgColor or rgbBkColor field (and the pixel value most closely matching that color is placed in the fgColor or bkColor field). If the current port is a grafPort, fgColor or bkColor is set to the old QuickDraw color determined by taking the high bit of each of the R, G, and B components, and using that three-bit number to select one of the eight QuickDraw colors. The ordering of the QuickDraw colors is shown in the GetForeColor description.
  18042. \ RGBBackColor
  18043. 2
  18044. Procedure RGBBackColor (color : RGBColor);
  18045.  
  18046.     These two calls set the foreground and background colors to the best available match for the current device. The only drawing operations that aren’t affected by these colors are PlotCIcon, and drawing using the new color patterns. Before you call CopyBits with a pixMap as the source, you should set the foreground to black and the background to white.
  18047.     If the current port is a cGrafPort, the specified RGB is placed in the rgbFgColor or rgbBkColor field (and the pixel value most closely matching that color is placed in the fgColor or bkColor field). If the current port is a grafPort, fgColor or bkColor is set to the old QuickDraw color determined by taking the high bit of each of the R, G, and B components, and using that three-bit number to select one of the eight QuickDraw colors. The ordering of the QuickDraw colors is shown in the GetForeColor description.
  18048. \ GetForeColor
  18049. 2
  18050. Procedure GetForeColor (VAR color : RGBColor);
  18051.  
  18052.     see GetBackColor.
  18053. \ GetBackColor
  18054. 2
  18055. Procedure GetBackColor (VAR color : RGBColor);
  18056.  
  18057.     These two calls return the RGB components of the foreground and background colors set in the current port. The calls work for both grafPorts and cGrafPorts. If the current port is a cGrafPort, the returned value is taken directly from the rgbFgColor or rgbBkColor field. If the current port is a grafPort, then only eight possible RGB values can be returned. These eight values are determined by the values in a global variable named QDColors, which is a pointer to a color table containing the current QuickDraw colors.
  18058.  
  18059. The colors are stored in the following order:
  18060.  
  18061.     Value   Color   Red Green   Blue
  18062.  
  18063.     0   black   $0000   $0000   $0000
  18064.     1   yellow  $FC00   $F37D   $052F
  18065.     2   magenta $F2D7   $0856   $84EC
  18066.     3   red     $DD6B   $08C2   $06A2
  18067.     4   cyan    $0241   $AB54   $EAFF
  18068.     5   green   $0000   $8000   $11B0
  18069.     6   blue    $0000   $0000   $D400
  18070.     7   white   $FFFF   $FFFF   $FFFF
  18071.  
  18072.     This is the set of colors that Color QuickDraw uses to determine precisely what colors should be displayed by an old grafPort that is using color. The default set of colors has been adjusted to match the colors produced on the ImageWriter II printer.
  18073. \ FillCRect
  18074. 2
  18075. Procedure FillCRect (r: Rect; ppat: PixPatHandle);
  18076.  
  18077.     see FillCPoly.
  18078. \ FillCOval
  18079. 2
  18080. Procedure FillCOval (r: Rect; ppat: PixPatHandle);
  18081.  
  18082.     see FillCPoly.
  18083. \ FillCRoundRect
  18084. 2
  18085. Procedure FillCRoundRect (r: Rect; ovWd,ovHt: INTEGER; ppat: PixPatHandle);
  18086.  
  18087.     see FillCPoly.
  18088. \ FillCArc
  18089. 2
  18090. Procedure FillCArc (r: Rect; startAngle,arcAngle: INTEGER; ppat: PixPatHandle);
  18091.  
  18092.     see FillCPoly.
  18093. \ FillCRgn
  18094. 2
  18095. Procedure FillCRgn (rgn: RgnHandle; ppat: PixPatHandle);
  18096.  
  18097.     see FillCPoly.
  18098. \ FillCPoly
  18099. 2
  18100. Procedure FillCPoly (poly: PolyHandle; ppat: PixPatHandle);
  18101.     These calls are analogous to their similarly named counterparts in QuickDraw. They allow a multicolored pattern to be used for filling.
  18102. \ GetCPixel
  18103. 2
  18104. Procedure GetCPixel (h,v: INTEGER; VAR cPix: RGBColor);
  18105.  
  18106.     The GetCPixel function returns the RGB of the pixel at the specified position in the current port.
  18107. \ SetCPixel
  18108. 2
  18109. Procedure SetCPixel (h,v: INTEGER; cPix: RGBColor);
  18110.  
  18111.     The SetCPixel function sets the pixel at the specified position to the pixel value that most closely matches the specified RGB.
  18112. \ NewPixMap
  18113. 2
  18114. Function NewPixMap : PixMapHandle;
  18115.  
  18116.     The NewPixMap function creates a new, initialized pixMap data structure and returns a handle to it. All fields of the pixMap are copied from the current device’s pixMap except the color table. A handle to the color table is allocated but not initialized.
  18117. \ DisposPixMap
  18118. 2
  18119. Procedure DisposPixMap (pm: PixMapHandle);
  18120.  
  18121.     The DisposPixMap procedure releases all storage allocated by NewPixMap. It disposes of the pixMap’s color table, and of the pixMap itself. Be careful not to dispose of a pixMap whose color table is the same as the current device’s color table.
  18122. \ CopyPixMap
  18123. 2
  18124. Procedure CopyPixMap (srcPM,dstPM: PixMapHandle);
  18125.  
  18126.     The CopyPixMap routine is used for duplicating the pixMap data structure. CopyPixMap copies the contents of the source pixMap data structure to the destination pixMap data structure. The contents of the color table are copied, so the destination pixMap has its own copy of the color table. Since the baseAddr field of the pixMap is a pointer, the pointer, but not the image itself, is copied.
  18127. \ CopyBits
  18128. 2
  18129. Procedure CopyBits (srcBits,dstBits: BitMap; srcRect, dstRect: Rect;  mode: INTEGER; maskRgn: RgnHandle);
  18130.  
  18131.     CopyBits now accepts either bitMaps or pixMaps as parameters. For convenience, just as you could pass the current port^.portBits as a parameter to CopyBits, you can now pass GrafPtr(cPort)^.portBits. (Recall that in a cGrafPort the high two bits of the portVersion field are set. This field, in the same position in the port as portBits.rowBytes, indicates to QuickDraw that it has been passed a portPixMap handle.)
  18132.     This call transfers an image from one bitMap or pixMap to another bitMap or pixMap. The source and destination may be of different depths, of different sizes, and they may have different color tables. Note, however, that the destination pixMap is assumed to use the same color table as the gDevice. (This is because an inverse table is required for translation to the destination’s color table.)
  18133.     During a CopyBits call, the foreground and background colors are applied to the image. To avoid unwanted coloring of the image, set the foreground to black and the background to white before calling this routine.
  18134. \ CopyMask
  18135. 2
  18136. Procedure CopyMask (srcBits,maskBits,dstBits: BitMap; srcRect,maskRect,dstRect: Rect);
  18137.  
  18138.     CopyMask is a new version of the CopyBits procedure, introduced in the Macintosh Plus. It transfers an image from the source to the destination only where the corresponding bit of the mask equals 1. The Macintosh II version will accept either a bitMap or pixMap as the srcBits or dstBits parameters. The maskBits parameter must be a bitMap.
  18139.     Like the Macintosh Plus version, CopyMask doesn’t send any of its drawing commands through grafProc routines; thus CopyMask calls are not recorded in pictures. Unlike the Macintosh Plus version, the Macintosh II version of CopyMask is able to stretch the source and mask to fit the dstRect. The srcRect and maskRect should be the same size. CopyMask uses the same low-level code as CopyBits, so all the same rules regarding depth translation and color table translation apply.
  18140.     During a CopyMask call, the foreground and background colors are applied to the image. To avoid unwanted coloring, set the foreground to black and the background to white before calling this routine.
  18141. \ SeedCFill
  18142. 2
  18143. Procedure SeedCFill  (srcBits, dstBits: BitMap; srcRect, dstRect: Rect; seedH, seedV: INTEGER; matchProc: ProcPtr; matchData: LONGINT);
  18144.  
  18145.     The SeedCFill procedure generates a mask for use with CopyMask or CopyBits, with bits equal to 1 only in those positions where paint can leak from the starting seed point, like the MacPaint® bucket tool.
  18146.     Given a rectangle within a source bitMap or pixMap (srcBits), SeedCFill returns a mask (dstBits) that contains 1’s in place of all pixels to which paint can leak from the specified seed position (seedH, seedV), expressed in the local coordinate system of the source pixMap. By default, paint can leak to all adjacent pixels whose RGB value exactly match that of the seed. To use this default, set matchProc and matchData to zero.
  18147.     In generating the mask, SeedCFill performs CopyBits to convert srcBits to a one-bit mask. It installs a default searchProc into the gDevice that returns 0 if the RGB value matches that of the seed; all other RGB values return 1’s.
  18148.     If you want to customize SeedCFill, your application can specify a matchProc that is used instead of the default searchProc. It should return 0’s for RGB values that you want to be filled, and 1’s for values that shouldn’t be filled. When the matchProc is called, the GDRefCon field of the current gDevice contains a pointer to a record having the following structure:
  18149.  
  18150. MatchRec = RECORD
  18151.     red:        INTEGER;
  18152.     green:      INTEGER;
  18153.     blue:       INTEGER;
  18154.     matchData:  LONGINT
  18155.     END;
  18156.  
  18157.     In this record the red, green, and blue fields are the RGB of the pixel at the specified seed location. MatchData is simply whatever value you passed to SeedCFill as a parameter. For instance, your application could pass a handle to a color table whose entries should all be filled, and then, in the matchProc, check to see if the specified RGB matches any of the colors in the table.
  18158.     No automatic scaling is performed: the source and destination rectangles must be the same size. Calls to SeedCFill are not clipped to the current port and are not stored into QuickDraw pictures.
  18159. \ CalcCMask
  18160. 2
  18161. Procedure CalcCMask (srcBits, dstBits: BitMap; srcRect, dstRect: Rect; seedRGB: RGBColor; matchProc: ProcPtr; matchData: LONGINT);
  18162.  
  18163.     This routine generates a mask (dstBits) corresponding to the area in a pixMap (srcBits) to which paint cannot leak from outside of the srcRect. The size of srcRect must be the same as the size of dstRect.  By default, paint can leak to all adjacent pixels whose RGB values don’t match that of the seedRGB. To use this default, set matchProc and matchData to 0.
  18164.     For instance, if srcBits contains a blue rectangle on a red background, and your application calls CalcCMask with the seedRGB equal to blue, then the returned mask has ones in the positions corresponding to the edges and interior of the rectangle, and zeros outside of the rectangle.
  18165.     If you want to customize CalcCMask, your application can specify a matchProc that is used instead of the default searchProc. It should return 1’s for RGB values that define the edges of the mask, and 0’s for values that don’t.
  18166.     When the matchProc is called, the GDRefCon field of the gDevice contains a pointer to a MatchRec record (the structure shown in the SeedCFill description). The red, green, and blue fields are the RGB of the pixel at the specifed seed location. MatchData is simply whatever value your application passed to CalcCMask as a parameter. For instance, your program could pass a handle to a color table whose entries should all be within the mask, and then, in the matchProc, check to see if the specified RGB matches any of the colors in the table.
  18167.     No automatic scaling is performed: the source and destination rectangles must be the same size. Calls to CalcCMask are not clipped to the current port and are not stored into QuickDraw pictures.
  18168. \ NewPixPat
  18169. 2
  18170. Function NewPixPat: PixPatHandle;
  18171.  
  18172.     The NewPixPat function creates a new pixPat data structure, and returns a handle to it. It calls NewPixMap to allocate and initialize the pattern’s pixMap to the same settings as theGDevice^^.GDPMap, and it sets the type of the pixPat to be a color pattern. The pat1Data field is initialized to a 50% gray pattern. New handles for data, expanded data, expanded map, and color table are allocated but not initialized. Including the pixPat itself, it allocates a total of six handles.  You will generally not need to use this routine since the GetPixPat routine can be used to read in a pattern from a resource file.
  18173.     The sizes of the pixMap and pixPat handles are the size of their respective data structures (see the type declarations in the “Summary” section). The other three handles are initially small in size. Once the pattern is drawn, the size of the expanded data is proportional to the size of the pattern data, but adjusted to the depth of the screen. The color table size is the size of the record structure plus eight bytes times the number of colors in the table.
  18174.  
  18175. Creating a PixPat
  18176.  
  18177.     To create a color pattern, use NewPixPat to allocate a new PixPatHandle. Set the rowBytes, bounds, and pixelSize of the pattern’s pixMap to the dimensions of the desired pattern. The rowBytes should be equal to (width of bounds)*pixelSize/8; it need not be even. The width and height of the bounds must be a power of two. Each scanline of the pattern must be at least one byte in length—that is, (width of bounds)*pixelSize must be at least eight. Set the other fields in the pattern’s pixMap as described in the section on the pixMap data structure.
  18178.     Your application can explicitly specify the color corresponding to each pixel value with the color table. The color table for the pattern must be placed in the pmTable in the pixPat’s pixMap. Patterns may also contain colors that are relative to the foreground and background at the time that they are drawn. Refer to the section on the pixPat data structure for more information on relative patterns.
  18179. \ DisposPixPat
  18180. 2
  18181. Procedure DisposPixPat (ppat: PixPatHandle);
  18182.  
  18183.     The DisposPixPat procedure releases all storage allocated by NewPixPat. It disposes of the pixPat’s data handle, expanded data handle, and pixMap handle.
  18184. \ CopyPixPat
  18185. 2
  18186. Procedure CopyPixPat (srcPP,dstPP: PixPatHandle);
  18187.  
  18188.     The CopyPixPat procedure copies the contents of the source pixPat to the destination pixPat. It entirely copies all fields in the source pixPat, including the contents of the data handle, expanded data handle, expanded map, pixMap handle, and color table.
  18189. \ GetPixPat
  18190. 2
  18191. Function GetPixPat (patID: INTEGER): PixPatHandle;
  18192.  
  18193.     The GetPixPat call creates a new pixPat data structure, and then uses the information in the resource of type 'ppat' and the specified ID to initialize the pixPat. The 'ppat' resource format is described in the section “Color QuickDraw Resource Formats”. If the resource with the specified ID is not found, then this routine returns a NIL handle.
  18194. \ MakeRGBPat
  18195. 2
  18196. Procedure MakeRGBPat (ppat: PixPatHandle; myColor: RGBColor);
  18197.  
  18198.     The MakeRGBPat procedure is a new call which generates a pixPat that approximates the specified color when drawn.  For example, if your application is drawing to a device that has 4 bits per pixel, you will only get 16 colors if you simply set the foreground color and draw. If you use MakeRGBPat to select a pattern, and then draw using that pattern, you will effectively get 125 different colors. More colors are theoretically possible; this implementation opted for a fast pattern selection rather than the best possible pattern selection. If the device has 8 bits per pixel, you will effectively get 2197 colors.
  18199.     Note that these patterns aren’t usually solid; they provide a wide selection of colors by alternating between colors with up to four colors in a pattern. For this reason lines that are one pixel wide may not look good using these patterns. For an RGB pattern, the patMap^^.bounds always contains (0, 0, 8, 8), and the patMap^^.rowbytes equals 2. Figure 5 shows how these colors are arranged.
  18200.     When MakeRGBPat creates a color table, it only fills in the last colorSpec field: the other colorSpec values are computed at the time the drawing actually takes place, using the current pixel depth for the system.
  18201.     Value   RGB
  18202.     0       computed RGB color
  18203.     1       computed RGB color
  18204.     2       computed RGB color
  18205.     3       computed RGB color
  18206.     4       RGBColor passed to MakeRGBPat routine
  18207. \ PenPixPat
  18208. 2
  18209. Procedure PenPixPat (ppat: PixPatHandle);
  18210.  
  18211.     see BackPixPat.
  18212. \ BackPixPat
  18213. 2
  18214. Procedure BackPixPat (ppat: PixPatHandle);
  18215.  
  18216.     The PenPixPat and BackPixPat calls are analogous to PenPat and BackPat, but use multicolor pixel patterns instead of old-style patterns.  If you try to use a pixel pattern in a grafPort, the data in the pat1Data field is placed into pnPat, bkPat, or fillPat.
  18217.     When your application sets a pixel pattern, the handle you provide is actually placed into the grafPort or cGrafPort. In this way, QuickDraw can expand the pattern once (saving it in the patXData field) when the pattern is first set, and won’t have to reexpand it each time you set the pattern.
  18218.     Since your handle is actually stored in the grafPort or cGrafPort, it’s considered bad form to dispose of a PixPatHandle that is currently set as the pnPixPat or bkPixPat. (Just in case you forget, QuickDraw will remove all references to your pattern from existing grafPorts or cGrafPorts when you dispose of it.)
  18219.     Using the old calls PenPat and BackPat, you can still set old-style patterns in a cGrafPort. If necessary, it creates a new pixPatHandle in which to store the pattern (because, as described above, pixPatHandles are owned by the application). As in old grafPorts, old-style patterns are drawn using the foreground and background colors at the time of drawing, not at the time the pattern is set.
  18220. \ GetCCursor
  18221. 2
  18222. Function GetCCursor (crsrID: INTEGER): CCrsrHandle;
  18223.  
  18224.     The GetCCursor call creates a new CCrsr data structure, then initializes it using the information in the resource of type 'crsr' with the specified ID. The 'crsr' resource format is described in the section “Color QuickDraw Resource Formats”. If the resource with the specified ID isn’t found, then this routine returns a NIL handle.
  18225.     Since GetCCursor creates a new CCrsr data structure each time it is called, your application shouldn’t call GetCCursor before each call to SetCCursor (unlike the way GetCursor/SetCursor were normally used).  GetCCursor doesn’t dispose or detach the resource, so resources of type 'crsr' should typically be purgeable.
  18226. \ SetCCursor
  18227. 2
  18228. Procedure  SetCCursor (cCrsr: CCrsrHandle);
  18229.  
  18230.     The SetCCursor procedure allows your application to set a multicolor cursor.  At the time the cursor is set, it’s expanded to the current screen depth so that it can be drawn rapidly.
  18231.     If your application has changed the cursor’s data or its color table, it must also invalidate the fields crsrXValid and crsrID (described in the section on the Color Cursor data structure), before calling SetCCursor.
  18232. \ DisposCCursor
  18233. 2
  18234. Procedure DisposCCursor(cCrsr: CCrsrHandle);
  18235.  
  18236.     The DisposCCursor procedure disposes all structures allocated by GetCCursor.
  18237. \ AllocCursor
  18238. 2
  18239. Procedure AllocCursor;
  18240.  
  18241.     The AllocCursor procedure reallocates cursor memory. Under normal circumstances, you should never need to use this call, since reallocation of cursor memory is only necessary after the depth of one of the screens has been changed.
  18242. \ GetCIcon
  18243. 2
  18244. Function GetCIcon(id: INTEGER): CIconHandle;
  18245.  
  18246.     The GetCIcon function allocates a CIcon data structure and initializes it using the information in the resource of type 'cicn' with the specified ID. It returns the handle to the icon’s data structure. If the specified resource isn’t found, a NIL handle is returned.
  18247.     The format of the 'cicn' resource is described in the section “Color QuickDraw Resource Formats”.
  18248.     Since GetCIcon creates a new CIcon data structure each time it is called, your application shouldn’t call GetCIcon before each call to PlotCIcon. GetCIcon doesn’t dispose or detach the resource, so resources of type 'cicn' should typically be purgeable.
  18249. \ DisposCIcon
  18250. 2
  18251. Procedure DisposCIcon(theIcon: CIconHandle);
  18252.  
  18253.     The DisposCIcon procedure disposes all structures allocated by GetCIcon.
  18254. \ PlotCIcon
  18255. 2
  18256. Procedure PlotCIcon(theRect: Rect; theIcon: CIconHandle);
  18257.  
  18258.     The PlotCIcon procedure draws the specified icon in the specified rectangle. The iconMask field of the CIcon determines which pixels of the iconPMap are drawn and which are not. Only pixels with 1’s in corresponding positions in the iconMask are drawn; all other pixels don’t affect the destination. If the screen depth is one or two bits per pixel, the iconBMap is used as the source instead of the iconPMap (unless the rowBytes field of iconBMap is 0, indicating that there is no iconBMap.
  18259.     When the icon is drawn, the boundsRect of the iconPMap is used as the image’s source rectangle. The icon and its mask are both stretched to the destination rectangle. The icon’s pixels are remapped to the current depth and color table, if necessary. The bounds fields of the iconPMap, iconBMap, and iconMask are expected to be equal in size.
  18260.     PlotCIcon is simply a structured call to CopyMask. As such, it doesn’t send any of its drawing commands through grafProc routines; thus, PlotCIcon calls are not recorded in pictures.
  18261. \ SetPortPix
  18262. 2
  18263. Procedure SetPortPix (pm: PixMapHandle);
  18264.  
  18265.     The SetPortPix call is analogous to SetPortBits, and should be used instead of SetPortBits for cGrafPorts. It replaces the portPixMap field of the current cGrafPort with the specified handle. SetPortPix has no effect when used with an old grafPort. If SetPortBits is called when the current port is a cGrafPort, it does nothing.
  18266. \ OpColor
  18267. 2
  18268. Procedure OpColor (color: RGBColor);
  18269.  
  18270.     If the current port is a cGrafPort, the OpColor procedure sets the red, green, and blue values used by the AddPin, SubPin, and Blend drawing modes. This information is actually stored in the grafVars handle in the cGrafPort, but you should never need to reference it directly. If the current port is a grafPort, OpColor has no effect.
  18271. \ HiliteColor
  18272. 2
  18273. Procedure HiliteColor (color:RGBColor);
  18274.  
  18275.     The highlight color is used by all drawing operations that use the highlight transfer mode. When a cGrafPort is created, its highlight color is initialized from the global variable HiliteRGB.  The HiliteColor procedure allows you to change the highlighting color used by the current port. This information is actually stored in the grafVars handle in the cGrafPort, but you should never need to reference it directly. If the current port is a grafPort, HiliteColor has no effect.
  18276. \ CharExtra
  18277. 2
  18278. Procedure CharExtra (extra:Fixed);
  18279.  
  18280.     The CharExtra procedure sets the cGrafPort’s charExtra field, which specifies the number of pixels by which to widen every character excluding the space character in a line of text. The charExtra field is stored in a compressed format based on the txSize field, so you must set txSize before calling CharExtra. The initial charExtra setting is 0. CharExtra will accept a negative number. CharExtra has no effect on grafPorts.
  18281. \ SetStdCProcs
  18282. 2
  18283. Procedure SetStdCProcs (VAR cProcs: CQDProcs);
  18284.  
  18285.     This procedure sets all the fields of the given CQDProcs record to point to the standard low-level routines. You can then change the ones you wish to point to your own routines. For example, if your procedure that processes picture comments is named MyComments, you will store @MyComments in the commentProc field of the CQD Procs record.
  18286.     When drawing in a cGrafPort, your application must always use SetStdCProcs instead of SetStdProcs.
  18287. \ GetCTable
  18288. 2
  18289. Function GetCTable (ctID: INTEGER): CTabHandle;
  18290.  
  18291.     The GetCTable routine allocates a new color table data structure, and initializes it using the information in the resource of type 'clut' having the specified ID.  If the specified resource is not found, a NIL handle is returned.
  18292.     If you place this handle into a pixMap, you should first dispose of the handle that was already there.
  18293.     The format of the 'clut' resource is given in the section “Color QuickDraw Resource Formats”.  Resource ID values 0..127 are reserved for system use. Any 'clut' resources defined by your application should have IDs in the range 128..1023. This value must be in the ctSeed field in the resource, and will be placed in the ctSeed field of the color table (for color table identification). All other possible seed values are used to identify newly created color tables, and color tables that have been modified.
  18294.     If you modify a color table, you should invalidate it by changing its ctSeed field. You can get a new unique value for ctSeed using the routine GetCTSeed, described in the Color Manager chapter.
  18295. \ DisposCTable
  18296. 2
  18297. Procedure DisposCTable(cTable: CTabHandle);
  18298.  
  18299.     The DisposCTable procedure disposes the handle allocated for a color table.
  18300. \ Color2Index
  18301. 42
  18302. Function Color2Index (rgb: RGBColor): LONGINT;
  18303.  
  18304.     The Color2Index routine finds the best available approximation to a given absolute color, using the list of search procedures in the current device record. It returns a longint, which is a pixel value padded with zeros in the high word. Since the colorSpec.value field is only a word, the result returned from Color2Index must be truncated to fit into a colorSpec. In pixMaps the .value is the low-order word of this index.
  18305.  
  18306.     Color2Index shouldn’t be called from a custom search procedure.
  18307. \ Index2Color
  18308. 42
  18309. Procedure Index2Color (index: LONGINT; VAR rgb: RGBColor);
  18310.  
  18311.     The Index2Color routine finds the RGB color corresponding to a given color table index. The desired pixel value is passed and the corresponding RGB value is returned in RGB. The routine takes a longint, which should be a pixel value padded with zeros in the high word (normally the compiler does this automatically). Normally, the RGB from the current device color table corresponding to the index is returned as the RGBColor. Notice that this is not necessarily the same color that was originally requested via RGBForeColor, RGBBackColor, SetCPixel, or Color2Index. This RGB is read from the current gDevice color table.
  18312. \ InvertColor
  18313. 42
  18314. Procedure InvertColor (VAR theColor: RGBColor);
  18315.  
  18316.     The InvertColor routine finds the complement of an absolute color, using the list of complement procedures in the current device record. The default complement procedure uses the 1’s complement of each component of the requested color.
  18317. \ RealColor
  18318. 42
  18319. Function RealColor (color: RGBColor) : BOOLEAN;
  18320.  
  18321.     The RealColor routine tells whether a given absolute color actually exists in the current device’s color table. This decision is based on the current resolution of the inverse table. For example, if the current iTabRes is four, RealColor returns TRUE if there exists a color that exactly matches the top four bits of red, green, and blue.
  18322. \ GetSubTable
  18323. 42
  18324. Procedure GetSubTable (myColors: CTabHandle; iTabRes:INTEGER; targetTbl: CTabHandle);
  18325.  
  18326.     The GetSubTable routine takes a ColorTable pointed at by myColors, and maps each RGB value into its nearest available match for each target table. These best matches are returned in the colorSpec.value fields of myColors. The values returned are best matches to the RGBColor in targetTbl and the returned indices are indices into targetTbl. Best matches are calculated using Color2Index and all applicable rules apply. A temporary inverse table is built, and then discarded. ITabRes controls the resolution of the iTable that is built. If targetTbl is NIL, then the current device’s color table is used, and the device’s inverse table is used rather than building a new one. To provide a different resolution than the current inverse table, provide an explicit targetTbl parameter; don’t pass a NIL parameter.
  18327.  
  18328. Warning:  Depending on the requested resolution, building the inverse table can require large amounts of temporary space in the application heap:  twice the size of the table itself, plus a fixed overhead for each inverse table resolution of 3–15K bytes.
  18329. \ MakeITable
  18330. 42
  18331. Procedure MakeITable (colorTab: CTabHandle; inverseTab: ITabHandle; res: INTEGER);
  18332.  
  18333.     The MakeITable routine generates an inverse table based on the current contents of the color table pointed to by CTabHandle, with a resolution of res bits per channel. Reserved color table pixel values are not included in the resultant color table. MakeITable tests its input parameters and will return an error in QDError if the resolution is less than three or greater than five. Passing a NIL parameter to CTabHandle or ITabHandle substitutes an appropriate handle from the current gDevice, while passing 0 for res substitutes the current gDevice’s preferred table resolution. These defaults can be used in any combination with explicit values, or with NIL parameters.
  18334.  
  18335.     This routine allows maximum precision in matching colors, even if colors in the color table differ by less than the resolution of the inverse table. Five-bit inverse tables are not needed when drawing in normal QuickDraw modes. However, the new QuickDraw transfer modes (add, subtract, blend, etc.) may require a 5-bit inverse table for best results with certain color tables. MakeITable returns a QDError if the destination inverse table memory cannot be allocated. The 'mitq' resource governs how much memory is allocated for temporary internal structures; this resource type is for internal use only.
  18336.  
  18337. Warning:  Depending on the requested resolution, building the inverse table can require large amounts of temporary space in the application heap:  twice the size of the table itself, plus a fixed overhead for each inverse table resolution of 3–15K bytes.
  18338. \ GetCTSeed
  18339. 42
  18340. Function GetCTSeed : LONGINT;
  18341.     The GetCTSeed function returns a unique seed value that can be used in the ctSeed field of a color table created by an application. This seed value guarantees that the color table will be recognized as distinct from the destination, and that color table translation will be performed properly. The return value will be greater than the value stored in minSeed.
  18342. \ ProtectEntry
  18343. 42
  18344. Procedure ProtectEntry (index: INTEGER; protect: BOOLEAN);
  18345.  
  18346.     The ProtectEntry procedure protects or removes protection from an entry in the current device’s color table, depending on the value of the protect parameter.  A protected entry can’t be changed by other clients.  It returns a protection error if it attempts to protect an already protected entry. However, it can remove protection from any entry.
  18347. \ ReserveEntry
  18348. 42
  18349. Procedure ReserveEntry (index: INTEGER; reserve: BOOLEAN);
  18350.  
  18351.     The ReserveEntry procedure reserves or dereserves an entry in the current color table, depending on the value of the reserve parameter.  A reserved entry cannot be matched by another client’s search procedure, and will never be returned to another client by Color2Index or other routines that depend on it (such as RGBForeColor, RGBBackColor, SetCPixel, and so forth).  You could use this routine to selectively protect a color for color table animation.
  18352.  
  18353.     ReserveEntry copies the low byte of gdID into the low byte of ColorSpec.value when reserving an entry, and leaves the high byte alone. It acts like a selective protection, and does not allow any changes if the current gdID is different than the one in the colorSpec.value field of the reserved entry. If a requested match is already reserved, ReserveEntry returns a protection error. Any entry can be dereserved.
  18354. \ SetEntries
  18355. 42
  18356. Procedure  SetEntries(start, count: INTEGER; aTable: CSpecArray);
  18357.  
  18358.     The SetEntries procedure sets a group of color table entries for the current gDevice, starting at a given position for the specified number of entries. The pointer aTable points into a cSpecArray, not into a color table.  The colorSpec.value field of the entries must be in the logical range for the target card’s assigned pixel depth. Thus, with a 4-bit pixel size, the colorSpec.value fields should be in the range 1 to 15. With an 8-bit pixel size the range is 0 to 255.  Note that all values are zero-based; for example, to set three entries, pass two in the count parameter.
  18359.  
  18360. Note:  Palette Manager routines should be used instead of the SetEntries routine for applications that will run in a multiscreen or multitasking environment.
  18361.  
  18362.     The SetEntries positional information works in logical space, rather than in the actual memory space used by the hardware. Requesting a change at position four in the color table may not modify color table entry four in the hardware, but it does correctly change the color on the screen for any pixels with a value of four in the video card. The SetEntries mode characterized by a start position and a length is called sequence mode. In this case, new colors are sequentially loaded into the hardware in the same order as the aTable, the clientID fields for changed entries are copied from the current device’s gdID field, and the colorSpec.value fields are ignored.
  18363.  
  18364.     The other SetEntries mode is called index mode. It allows the cSpecArray to specify where the data will be installed on an entry-by-entry basis. To use this mode, pass –1 for the start position, with a valid count and a pointer to the cSpecArray. Each entry is installed into the color table at the position specified by the colorSpec.value field of each entry in the cSpecArray. In the current device’s color table, all changed entries’ colorSpec.value fields are assigned the gdID value.
  18365.  
  18366.     When color table entries are changed, all cached fonts are invalidated, and the seed number is changed so that the next drawing operation will rebuild the inverse table. If any of the requested entries are protected or out of range, a protection error is returned, and nothing happens. If a requested entry is reserved, it can only be changed if the current gdID matches the low byte of the intended ColorSpec.value field.
  18367. \ SaveEntries
  18368. 42
  18369. Procedure SaveEntries (srcTable: CTabHandle; ResultTable: CTabHandle; VAR  selection: ReqListRec);
  18370.  
  18371.     SaveEntries saves a selection of entries from srcTable into resultTable. The entries to be set are enumerated in the selection parameter, which uses the ReqListRec data structure shown below. (These values are offsets into colorTable, not the contents of the colorSpec.value field.)
  18372.  
  18373. TYPE
  18374.   ReqListRec = RECORD
  18375.         reqLSize:   INTEGER;    {request list }
  18376.                 { size –1}
  18377.         reqLData:   ARRAY [0..0] of INTEGER {request list }
  18378.                 { data}
  18379.                END;
  18380.  
  18381.     If an entry is not present in srcTable, then that position of the requestList is set to colReqErr, and that position of resultTable has random values returned. If one or more entries are not found, then an error code is posted to QDError; however, for every entry in selection which is not colReqErr, the values in resultTable are valid. Note that srcTable and selection are assumed to have the same number of entries.
  18382.  
  18383.     SaveEntries optionally allows NIL as its source color table parameter. If NIL is used, the current device’s color table is used as the source. The output of SaveEntries is the same as the input for RestoreEntries, except for the order.
  18384. \ RestoreEntries
  18385. 42
  18386. Procedure RestoreEntries (srcTable:CTabHandle;DstTable:CTabHandle; VAR selection:RecListRec);
  18387.  
  18388.     RestoreEntries sets a selection of entries from srcTable into dstTable, but doesn’t rebuild the inverse table. The dstTable entries to be set are enumerated in the selection parameter, which uses the ReqListRec data structure shown in the SetEntries routine description. (These values are offsets into the srcTable, not the contents of the colorSpec.value field.)
  18389.  
  18390.     If a request is beyond the end of the dstTable, that position of the requestList is set to colReqErr, and an error is returned. Note that srcTable and selection are assumed to have the same number of entries.
  18391.  
  18392.     If dstTbl is NIL, or points to the device color table, the current device’s color table is updated, and the hardware is updated to these new colors. The seed is not changed, so no invalidation occurs (this may cause RGBForeColor to act strangely). This routine ignores protection and reservation of color table entries.
  18393.  
  18394.     Generally, the Palette Manager is used to give an application its own set of colors; use of RestoreEntries should be limited to special-purpose applications. RestoreEntries allows you to change the colorTable without changing the ctSeed for the affected colorTable. You can execute the application code and then use RestoreEntries to put the original colors back in. However, in some cases things in the background may appear in the wrong colors, since they were never redrawn. To avoid this, the application must build its own new inverse table and redraw the background. If RestoreEntries were then used, the ctSeed would have to be explicitly changed to clean up correctly.
  18395. \ SearchProc
  18396. 42
  18397. Function SearchProc (rgb: RGBColor; VAR position: LONGINT): BOOLEAN;
  18398.  
  18399.     When attempting to approximate a color, the Color Manager calls each search procedure in the list until the boolean value returns as TRUE.  The index value of the closest match is returned by the position parameter.  If no search procedure installed in the linked list returns TRUE, the Color Manager calls the default search procedure.
  18400.  
  18401.     The application can also supply a custom complement procedure to find the complement of a specified color. Complement procedures work the same as search procedures, and are kept in a list beginning in the gDevice port’s gdCompProc field.
  18402.  
  18403.     TYPE
  18404.        CProcHndl   = ^CProcPtr;
  18405.        CProcPtr    = ^CProcRec;
  18406.        CProcRec    = RECORD
  18407.             nxtComp:    CProcHandle;    {pointer to next }
  18408.                     { CProcRec}
  18409.             compProc:   ProcPtr {pointer to complement }
  18410.                     { procedure}
  18411.                      END;
  18412.  
  18413.  
  18414.     The default complement procedure simply uses the 1’s complement of the RGB color components before looking them up in the inverse table. The interface is as follows:
  18415. \ CompProc
  18416. 42
  18417. Procedure CompProc (VAR rgb: RGBColor);
  18418.  
  18419.     Operations on Search and Complement Procedures
  18420. \ AddSearch
  18421. 42
  18422. Procedure AddSearch (searchProc: ProcPtr);
  18423.  
  18424.     The AddSearch routines add a procedure to the head of the current device record’s list of search or complement procedures. These routines allocate an SProcRec or CProcRec.
  18425. \ AddComp
  18426. 42
  18427. Procedure AddComp (compProc: ProcPtr);
  18428.  
  18429.     The AddComp routines add a procedure to the head of the current device record’s list of search or complement procedures. These routines allocate an SProcRec or CProcRec.
  18430. \ DelSearch
  18431. 42
  18432. Procedure DelSearch (searchProc: ProcPtr);
  18433.  
  18434.     The DelSearch procedures remove a custom search or complement procedure from the current device record’s list of search or complement procedures. These routines dispose of the chain element, but do nothing to the procPtr.
  18435. \ DelComp
  18436. 42
  18437. Procedure DelComp   (compProc: ProcPtr);
  18438.  
  18439.     The DelComp procedures remove a custom search or complement procedure from the current device record’s list of search or complement procedures. These routines dispose of the chain element, but do nothing to the procPtr.
  18440. \ SetClientID
  18441. 42
  18442. Procedure SetClientID (id: INTEGER);
  18443.  
  18444.     The SetClientID procedure sets the gdID field in the current device record to identify this client program to its search and complement procedures.
  18445. \ NewGDevice
  18446. 44
  18447. Function NewGDevice(refNum: INTEGER; mode: LONGINT)  GDHandle;
  18448.  
  18449.     The NewGDevice function allocates a new gDevice data structure and all of its handles, then calls InitGDevice to initialize it for the specified device in the specified mode.  If the request is unsuccessful, a NIL handle is returned.  The new gDevice and all of its handles are allocated in the system heap. All attributes in the GDFlags word are set to FALSE.
  18450.     If your application creates a gDevice without a driver, the mode parameter should be set to –1.  In this case, InitGDevice is not called to initialize the gDevice.  Your application must perform all initialization.
  18451.     A graphics device’s default mode is defined as 128, as described in the Designing Cards and Drivers manual; this is assumed to be a monochrome mode. If the mode parameter is not the default mode, the gdDevType attribute is set TRUE, to indicate that the device is capable of displaying color (see the SetDeviceAttribute call).
  18452.     This routine doesn’t automatically insert the gDevice into the device list.  In general, your application shouldn’t add devices that it created to the device list.
  18453.  
  18454. \ InitGDevice
  18455. 44
  18456. Procedure InitGDevice(gdRefNum: INTEGER; mode: LONGINT; gdh: GDHandle);
  18457.  
  18458.     The InitGDevice routine sets the video device whose driver has the specified gdRefNum to the specified mode. It then fills out the gDevice record structure specified by the gdh parameter to contain all information describing that mode. The GDHandle should have been allocated by a call to NewGDevice.
  18459.     The mode determines the configuration of the device;  possible modes for a device can be determined by interrogating the video card’s ROM via calls to the Slot Manager (refer to the Slot Manager chapter and the Designing Cards and Drivers manual).  Refer to the Device Manager chapter for more details about the interaction of devices and their drivers.
  18460.     The information describing the new mode is primarily contained in the video card’s ROM.  If the device has a fixed color table, then that table is read directly from the ROM.  If the device has a variable color table, then the default color table for that depth is used (the 'clut' resource with ID=depth).
  18461.     In general, your application should never need to call this routine.  All video devices are initialized at start time and their modes are changed by the control panel.  If your program is initializing a device without a driver, this call will do nothing; your application must initialize all fields of the gDevice.  It is worth noting that after your program initializes the color table for the device, it needs to call MakeITable to build the inverse table for the device.
  18462. \ GetGDevice
  18463. 44
  18464. Function GetGDevice: GDHandle;
  18465.  
  18466.     The GetGDevice routine returns a handle to the current gDevice.  This is useful for determining the characteristics of the current output device (for instance its pixelSize or color table).  Note that since a window can span screen boundaries, this call does not return the device that describes a port.
  18467.  
  18468. Assembly-language note:  A handle to the currently active device is kept in the global variable TheGDevice.
  18469. \ SetGDevice
  18470. 44
  18471. Procedure SetGDevice(gdh: GDHandle);
  18472.  
  18473.     The SetGDevice procedure sets the specified gDevice as the current device.  Your application won’t generally need to use this call except to draw to offscreen gDevices.
  18474. \ DisposGDevice
  18475. 44
  18476. Function DisposGDevice: GDHandle;
  18477.  
  18478.     The DisposGDevice function disposes of the current gDevice and releases the space allocated for it, and all data structures allocated by NewGDevice.
  18479. \ GetDeviceList
  18480. 44
  18481. Function GetDeviceList: GDHandle;
  18482.  
  18483.     The GetDeviceList function returns a handle to the first device in the DeviceList.
  18484.  
  18485. Assembly-language note:  A handle to the first element in the device list is kept in the global variable DeviceList.
  18486. \ GetMainDevice
  18487. 44
  18488. Function GetMainDevice: GDHandle;
  18489.  
  18490.     The GetMainDevice function returns the handle of the gDevice that has the menu bar on it.  Your application can examine this gDevice to determine the size or depth of the main screen.
  18491.  
  18492. Assembly-language note:  A handle to the current main device is kept in the global variable MainDevice.
  18493. \ GetNextDevice
  18494. 44
  18495. Function GetNextDevice (gdh: GDHandle): GDHandle;
  18496.  
  18497.     The GetNextDevice function returns the handle of the next gDevice in the DeviceList.  If there are no more devices in the list, it returns NIL.
  18498. \ SetDeviceAttribute
  18499. 44
  18500. Procedure SetDeviceAttribute: (gdh: GDHandle; attribute: INTEGER; value: BOOLEAN);
  18501.  
  18502.     The SetDeviceAttribute routine can be used to set a device’s attribute bits. The following attributes may be set using this call:
  18503.  
  18504. gdDevType   = 0;    {0 = monochrome, 1 = color}
  18505. ramInit     = 10;   {set if device has been initialized from RAM}
  18506. mainScreen  = 11;   {set if device is main screen}
  18507. allInit     = 12;   {set if devices were initialized from a }
  18508.                     { 'scrn' resource}
  18509. screenDevice= 13;   {set if device is a screen device}
  18510. noDriver    = 14;   {set if device has no driver}
  18511. screenActive= 15;   {set if device is active}
  18512. \ TestDeviceAttribute
  18513. 44
  18514. Function TestDeviceAttribute (curDevice: GDHandle; attribute: INTEGER) : BOOLEAN;
  18515.  
  18516.     The TestDeviceAttribute function tests a single attribute to see if it is true or not.  If your application is scanning through the device list, it would typically use this routine to test if a device is a screen device, and if so, test to see if it’s active. Then your application can draw to any active screen devices.
  18517. \ GetMaxDevice
  18518. 44
  18519. Function GetMaxDevice (globalRect: Rect):GDHandle;
  18520.  
  18521.     The GetMaxDevice routine returns a handle to the deepest device that intersects the specified global rectangle. Your application might use this routine to allocate offscreen pixMaps, as described in the following section.
  18522. \ OpenXPP
  18523. 23
  18524. Function OpenXPP(VAR xppRefnum: INTEGER): OSErr;
  18525.  
  18526. \ ASPOpenSession
  18527. 23
  18528. Function ASPOpenSession(xParamBlock: XPPParmBlkPtr; async: BOOLEAN): OSErr;
  18529.  
  18530. \ ASPCloseSession
  18531. 23
  18532. Function ASPCloseSession(xParamBlock: XPPParmBlkPtr; async: BOOLEAN): OSErr;
  18533.  
  18534. \ ASPAbortOS
  18535. 23
  18536. Function ASPAbortOS(xParamBlock: XPPParmBlkPtr; async: BOOLEAN): OSErr;
  18537.  
  18538. \ ASPGetParms
  18539. 23
  18540. Function ASPGetParms(xParamBlock: XPPParmBlkPtr; async: BOOLEAN): OSErr;
  18541.  
  18542. \ ASPCloseAll
  18543. 23
  18544. Function ASPCloseAll(xParamBlock: XPPParmBlkPtr; async: BOOLEAN): OSErr;
  18545.  
  18546. \ ASPUserWrite
  18547. 23
  18548. Function ASPUserWrite(xParamBlock: XPPParmBlkPtr; async: BOOLEAN): OSErr;
  18549.  
  18550. \ ASPUserCommand
  18551. 23
  18552. Function ASPUserCommand(xParamBlock: XPPParmBlkPtr; async: BOOLEAN): OSErr;
  18553.  
  18554. \ ASPGetStatus
  18555. 23
  18556. Function ASPGetStatus(xParamBlock: XPPParmBlkPtr; async: BOOLEAN): OSErr;
  18557.  
  18558. \ AFPCommand
  18559. 23
  18560. Function AFPCommand(xParamBlock: XPPParmBlkPtr; async: BOOLEAN): OSErr;
  18561.  
  18562. \ PAttachPH
  18563. 23
  18564. Function PAttachPH(thePBptr:MPPPBptr;async:BOOLEAN): OSErr;
  18565.  
  18566. \ PDetachPH
  18567. 23
  18568. Function PDetachPH(thePBptr:MPPPBptr;async:BOOLEAN): OSErr;
  18569.  
  18570. \ PWriteLAP
  18571. 23
  18572. Function PWriteLAP(thePBptr:MPPPBptr;async:BOOLEAN): OSErr;
  18573.  
  18574. \ POpenSkt
  18575. 23
  18576. Function POpenSkt(thePBptr:MPPPBptr;async:BOOLEAN): OSErr;
  18577.  
  18578. \ PCloseSkt
  18579. 23
  18580. Function PCloseSkt(thePBptr:MPPPBptr;async:BOOLEAN): OSErr;
  18581.  
  18582. \ PWriteDDP
  18583. 23
  18584. Function PWriteDDP(thePBptr:MPPPBptr;async:BOOLEAN): OSErr;
  18585.  
  18586. \ PRegisterName
  18587. 23
  18588. Function PRegisterName(thePBptr:MPPPBptr;async:BOOLEAN): OSErr;
  18589.  
  18590. \ PLookupName
  18591. 23
  18592. Function PLookupName(thePBptr:MPPPBptr;async:BOOLEAN): OSErr;
  18593.  
  18594. \ PConfirmName
  18595. 23
  18596. Function PConfirmName(thePBptr:MPPPBptr;async:BOOLEAN): OSErr;
  18597.  
  18598. \ PRemoveName
  18599. 23
  18600. Function PRemoveName(thePBptr:MPPPBptr;async:BOOLEAN): OSErr;
  18601.  
  18602. \ PKillNBP
  18603. 23
  18604. Function PKillNBP(thePBptr:MPPPBptr;async:BOOLEAN): OSErr;
  18605.  
  18606. \ PSetSelfSend
  18607. 23
  18608. Function PSetSelfSend(thePBptr:MPPPBptr;async:BOOLEAN): OSErr;
  18609.  
  18610. \ POpenATPSkt
  18611. 23
  18612. Function POpenATPSkt(thePBptr:ATPPBptr;async:BOOLEAN): OSErr;
  18613.  
  18614. \ PCloseATPSkt
  18615. 23
  18616. Function PCloseATPSkt(thePBptr:ATPPBptr;async:BOOLEAN): OSErr;
  18617.  
  18618. \ PSendRequest
  18619. 23
  18620. Function PSendRequest(thePBptr:ATPPBptr;async:BOOLEAN): OSErr;
  18621.  
  18622. \ PGetRequest
  18623. 23
  18624. Function PGetRequest(thePBptr:ATPPBptr;async:BOOLEAN): OSErr;
  18625.  
  18626. \ PSendResponse
  18627. 23
  18628. Function PSendResponse(thePBptr:ATPPBptr;async:BOOLEAN): OSErr;
  18629.  
  18630. \ PAddResponse
  18631. 23
  18632. Function PAddResponse(thePBptr:ATPPBptr;async:BOOLEAN): OSErr;
  18633.  
  18634. \ PRelTCB
  18635. 23
  18636. Function PRelTCB(thePBptr:ATPPBptr;async:BOOLEAN): OSErr;
  18637.  
  18638. \ PRelRspCB
  18639. 23
  18640. Function PRelRspCB(thePBptr:ATPPBptr;async:BOOLEAN): OSErr;
  18641.  
  18642. \ PNSendRequest
  18643. 23
  18644. Function PNSendRequest(thePBptr:ATPPBptr;async:BOOLEAN): OSErr;
  18645.  
  18646. \ PKillSendReq
  18647. 23
  18648. Function PKillSendReq(thePBptr:ATPPBptr;async:BOOLEAN): OSErr;
  18649.  
  18650. \ PKillGetReq
  18651. 23
  18652. Function PKillGetReq(thePBptr:ATPPBptr;async:BOOLEAN): OSErr;
  18653.  
  18654. \ BuildLAPwds
  18655. 23
  18656. Procedure BuildLAPwds(wdsPtr,dataPtr:Ptr;destHost,prototype,frameLen:INTEGER);
  18657.  
  18658. \ BuildDDPwds
  18659. 23
  18660. Procedure BuildDDPwds( wdsPtr,headerPtr,dataPtr:Ptr;
  18661.       destAddress:AddrBlock;ddpType:INTEGER;dataLen:INTEGER);
  18662.  
  18663. \ NBPSetEntity
  18664. 23
  18665. Procedure NBPSetEntity(buffer:Ptr;nbpObject,nbpType,nbpZone:Str32);
  18666.  
  18667. \ NBPSetNTE
  18668. 23
  18669. Procedure NBPSetNTE(ntePtr:Ptr;nbpObject,nbpType,nbpZone:Str32;socket:INTEGER);
  18670.  
  18671. \ GetBridgeAddress
  18672. 23
  18673. Function GetBridgeAddress:INTEGER;
  18674.  
  18675. \ BuildBDS
  18676. 23
  18677. Function BuildBDS(buffPtr,bdsPtr:Ptr;buffSize:INTEGER):INTEGER;
  18678.  
  18679. \ LAPCloseProtocol
  18680. 23
  18681. Function LAPCloseProtocol(theLAPType: ABByte): OSErr;
  18682.  
  18683. \ RemoveHdlBlocks
  18684. 23
  18685. Procedure RemoveHdlBlocks;
  18686. \ NewCWindow
  18687. 5
  18688. Function NewCWindow (wStorage: Ptr; boundsRect: Rect; title: Str255; visible: BOOLEAN; procID: INTEGER; behind: WindowPtr; goAwayFlag: BOOLEAN; refCon: LONGINT) : CWindowPtr; [Macintosh II]
  18689.  
  18690.     The NewCWindow routine creates a new color window.  This routine is similar to the old routine NewWindow, but creates a window based on a cGrafPort instead of an old-style grafPort.
  18691. \ GetNewCWindow
  18692. 5
  18693. Function GetNewCWindow (windowID: INTEGER; wStorage: Ptr; behind: CWindowPtr) : CWindowPtr; [Macintosh II]
  18694.  
  18695.     The GetNewCWindow routine creates a new color window from a template in a resource file. It’s analogous to the old routine GetNewWindow, but it creates a window based on a cGrafPort instead of an old-style grafPort. GetNewCWindow checks the 'wctb' resource, and if it contains the same resource ID, it colors the window. The backColor of the window is set to the new content color. This allows an application to begin its update with an EraseRect without changing the background color.
  18696. \ SetWinColor
  18697. 5
  18698. Procedure SetWinColor (theWindow: WindowPtr; newColorTable: CTabHandle); [Macintosh II]
  18699.  
  18700.     The SetWinColor routine sets a window’s color table.  If the window currently has no auxiliary window record, a new one is created with the given color table and added to the head of the auxiliary window list.  If there is already an auxiliary record for the window, its color table is replaced by the contents of newColorTable. The window is then automatically redrawn in the new colors. If SetWinColor is performed on a cWindow, it sets the backColor of the window to the new content color. This allows an application to begin its update without changing the background color.
  18701.     If newColorTable has the same contents as the default color table, the window’s existing auxiliary record and color table are removed from the auxiliary window list and deallocated.  If theWindow = NIL, the operation modifies the default color table in memory. The system never disposes of color tables that are resources when the resource bit is set; 'wctb' resources can’t be purgeable.
  18702. \ GetAuxWin
  18703. 5
  18704. Function GetAuxWin (theWindow: WindowPtr; VAR colors: CTabHandle) : BOOLEAN; [Macintosh II]
  18705.  
  18706.     The GetAuxWin routine returns a handle to a window’s auxiliary window record:
  18707.  
  18708. - If the given window has an auxiliary record, its handle is returned in colors and the function returns TRUE.
  18709. - If the window has no auxiliary record, a handle to the default record is returned in colors and the function returns FALSE.
  18710. - If theWindow = NIL, a handle to the default record is returned in colors and the function returns TRUE.
  18711. \ GetWVariant
  18712. 5
  18713. Function GetWVariant (whichWindow:WindowPtr): INTEGER; [Macintosh Plus, Macintosh SE, Macintosh II]
  18714.  
  18715.     GetWVariant returns the variant code for the window described by whichWindow. See the Window Manager chapter in Volume I for more information about variants.
  18716. \ GetGrayRgn
  18717. 5
  18718. Function GetGrayRgn : regionHandle;  [Macintosh Plus, Macintosh SE, Macintosh II]
  18719.  
  18720.     The GetGrayRgn function returns a handle to the current desktop region stored in the global variable GrayRgn.
  18721. \ NewCDialog
  18722. 9
  18723. Function NewCDialog (dStorage:  Ptr; boundsRect:  Rect; title:  Str255; visible:  BOOLEAN; procID:  INTEGER; behind:  WindowPtr; goAwayFlag:  BOOLEAN; refCon:  LONGINT; items:  Handle) :  CDialogPtr;
  18724.  
  18725.     A new Dialog Manager routine has been added to support color dialogs: NewCDialog.  Its parameters are identical to NewDialog, except that a cGrafPort is allocated through a NewCWindow call instead of a call to NewWindow.
  18726.  
  18727.     NewCDialog creates a dialog box as specified by its parameters and returns a cDialogPtr to the new dialog. The first eight parameters (dStorage through refCon) are passed to the Window Manager function NewCWindow, which creates the dialog window. The items parameter is a handle to the dialog’s item list. You can get the items handle by calling the Resource Manager to read the item list from the resource file into memory.
  18728.  
  18729.     After calling NewCDialog, you can use SetWinColor to add a color table to the dialog. This creates an auxiliary window record (auxWinRec) for the dialog window. You can access this record with the GetAuxWin routine. The dialogCItem handle within the auxWinRec points to the dialog item color table.
  18730.  
  18731.     If the dialog’s content color isn’t white, it’s a good idea to call NewCDialog with the visible flag set to FALSE. After the color table and color item list are installed, use ShowWindow to display the dialog if the dialog is the frontmost window. If the dialog is not in front, use ShowHide to display the dialog.
  18732. \ PrStlInit
  18733. 18
  18734. Function PrStlInit(hPrint: THPrint): TPPrDlg;
  18735.  
  18736. \ PrJobInit
  18737. 18
  18738. Function PrJobInit(hPrint: THPrint): TPPrDlg;
  18739.  
  18740. \ PrDlgMain
  18741. 18
  18742. Function PrDlgMain(hPrint: THPrint; pDlgInit: ProcPtr): Boolean;
  18743. \ PrGeneral
  18744. 18
  18745. Procedure PrGeneral (pData: Ptr);
  18746.  
  18747. The pData parameter is a pointer to a data block.  The structure of the data block is declared as follows:
  18748.  
  18749.     TGnlData = RECORD
  18750.         {1st 8 bytes are common for all PrGeneral calls);
  18751.         iOpCode: Integer;   {input}
  18752.         iError: Integer;    {output}
  18753.         lReserved: LongInt; {reserved for future use}
  18754.         {more fields here, depending on particular call}
  18755.        END;
  18756.  
  18757.     The first field in the TGnlData record is a 2-byte opcode, iOpCode, which acts somewhat like a routine selector.   The currently available opcodes are these:
  18758.  
  18759. - GetRslData (get resolution data): iOpCode = 4
  18760. - SetRsl (set resolution): iOpCode = 5
  18761. - DraftBits (bitmaps in draft mode): iOpCode = 6
  18762. - NoDraftBits (no bitmaps in draft mode): iOpCode = 7
  18763. - GetRotn (get rotation): iOpCode = 8
  18764.  
  18765.     GetRslData and SetRsl allow the application to find out what physical resolutions the printer supports, and then specify a supported resolution.  DraftBits and noDraftBits invoke a new feature of the ImageWriter, allowing bitmaps (imaged via CopyBits) to be printed in draft mode.  GetRotn lets an application know whether landscape orientation has been selected.  These routines are described in the next sections.
  18766.  
  18767.     The second field in the TGnlData record is the error result, iError, returned by the print code.   This error only reflects error conditions that occur during the PrGeneral call.  For example, if you use an opcode that isn’t implemented in a particular printer driver then you will get an OpNotImpl error.  Here are the error codes:
  18768.  
  18769. CONST
  18770.     NoErr     = 0; {no error}
  18771.     NoSuchRsl = 1; {the resolution you chose isn't available}
  18772.     OpNotImpl = 2; {the driver doesn't support this opcode}
  18773.  
  18774.     After calling PrGeneral you should always check PrError.  If NoErr is returned, then you can proceed. If ResNotFound is returned, then the current printer driver doesn’t support PrGeneral and you should proceed appropriately.
  18775.  
  18776.     IError is followed by a four byte reserved field.  The contents of the rest of the data block depends on the opcode that the application uses.
  18777.  
  18778.  
  18779. GetRslData
  18780.  
  18781.     GetRslData (iOpCode = 4) returns a record that lets the application know what resolutions are supported by the current printer.  The application can then use SetRsl to tell the printer driver which one it will use.  These calls introduce a good deal of complexity into your application’s code, and should be used only when necessary.
  18782.  
  18783. This is the format of the input data block for the GetRslData call:
  18784.  
  18785.     TRslRg = RECORD {used in TGetRslBlk}
  18786.         iMin: Integer;  {0 if printer supports only discrete resolutions}
  18787.         iMax: Integer;  {0 if printer supports only discrete resolutions}
  18788.       END;
  18789.  
  18790.     TRslRec = RECORD    {used in TGetRslBlk}
  18791.         iXRsl:  Integer;    {a discrete, physical X resolution}
  18792.         iYRsl:  Integer;    {a discrete, physical Y resolution}
  18793.       END;
  18794.  
  18795.     TGetRslBlk = RECORD {data block for GetRslData call}
  18796.         iOpCode: Integer;       {input; = getRslDataOp}
  18797.         iError: Integer;        {output}
  18798.         lReserved: LongInt;     {reserved for future use}
  18799.         iRgType: Integer;       {output; version number}
  18800.         XRslRg: TRslRg;         {output; range of X resolutions}
  18801.         YRslRg: TRslRg;         {output; range of Y resolutions}
  18802.         iRslRecCnt: Integer;    {output; how many RslRecs follow}
  18803.         rgRslRec:   ARRAY[1..27] OF TRslRec; {output; number filled }
  18804.                                            { depends on printer type}
  18805.        END;
  18806.  
  18807.     The iRgType field is much like a version number; it determines the interpretation of the data that follows.  An iRgType value of 1 applies both to the LaserWriter and to the ImageWriter.
  18808.  
  18809.     For variable-resolution printers like the LaserWriter, the resolution range fields XRslRg and YRslRg express the ranges of values to which the X and Y resolutions can be set.  For discrete-resolution printers like the ImageWriter, the values in the resolution range fields are zero.
  18810.  
  18811. Note:  In general, X and Y in these records are the horizontal and vertical directions of the printer, not the document.  In “landscape” orientation, X is horizontal on the printer but vertical on the document.
  18812.  
  18813.     After the resolution range information there is a word which gives the number of resolution records that contain information.  These records indicate the physical resolutions at which the printer can actually print dots.  Each resolution record gives an X value and a Y value.
  18814.  
  18815.     Notice that all the resolution range numbers are the same for this printer.  There is only one resolution record, which gives the physical X and Y resolutions of the printer (300 x 300).
  18816.  
  18817.     All the resolution range values are zero, because only discrete resolutions can be specified for the ImageWriter.  There are four resolution records giving these discrete physical resolutions.
  18818.  
  18819.     GetRslData always returns the same information for a particular printer type—it is not dependent on what the user does or on printer configuration information.
  18820.  
  18821.  
  18822. SetRsl
  18823.  
  18824.     SetRsl (iOpCode = 5) is used to specify the desired imaging resolution, after using GetRslData to determine a workable pair of values.  Below is the format of the data block:
  18825.  
  18826.     TSetRslBlk =    RECORD  {data block for SetRsl call}
  18827.         iOpCode: Integer;   {input; = setRslOp}
  18828.         iError: Integer;    {output}
  18829.         lReserved: LongInt; {reserved for future use}
  18830.         hPrint: THPrint;    {input; handle to a valid print record}
  18831.         iXRsl:  Integer;    {input; desired X resolution}
  18832.         iYRsl:  Integer;    {input; desired Y resolution}
  18833.     END;
  18834.  
  18835.     The hPrint parameter contains the handle of a print record that has previously been passed to PrValidate.  If the call executes successfully, the print record is updated with the new resolution; the data block comes back with 0 for the error and is otherwise unchanged.  If the desired resolution is not supported, the error is set to noSuchRsl and the resolution fields are set to the printer’s default resolution
  18836.  
  18837.     You can undo the effect of a previous call to SetRsl by making another call that specifies an unsupported resolution (such as 0 x 0), forcing the default resolution.
  18838.  
  18839.  
  18840. DraftBits
  18841.  
  18842.     DraftBits (iOpCode = 6) is implemented on both the ImageWriter and the LaserWriter.  On the LaserWriter it does nothing, because the LaserWriter is always in draft mode and can always print bitmaps.  Here is the format of the data block:
  18843.  
  18844.     TDftBitsBlk = RECORD {data block for DraftBits and NoDraftBits calls}
  18845.         iOpCode: Integer;   {input; = draftBitsOp or noDraftBitsOp}
  18846.         iError: Integer;    {output}
  18847.         lReserved: LongInt; {reserved for future use}
  18848.         hPrint: THPrint;    {input; handle to a valid print record}
  18849.     END;
  18850.  
  18851.     The hPrint parameter contains the handle of a print record that has previously been passed to PrValidate.
  18852.  
  18853.     This call forces draft-mode (immediate) printing, and will allow bitmaps to be printed  via CopyBits calls.  The virtue of this is that you avoid spooling large masses of bitmap data onto the disk, and you also get better performance.
  18854.  
  18855.  
  18856. The following restrictions apply:
  18857.  
  18858. - This call should be made before bringing up the print dialog boxes because it affects their appearance.  On the ImageWriter, calling DraftBits disables the landscape icon in the Style dialog, and the Best, Faster, and Draft buttons in the Job dialog box.
  18859. - If the printer does not support draft mode, already prints bitmaps in draft mode, or does not print bitmaps at all, this call does nothing.
  18860. - Only text and bitmaps can be printed.
  18861. - As in the normal draft mode, landscape format is not allowed.
  18862. - Everything on the page must be strictly Y-sorted; that is, no reverse paper motion between one string or bitmap and the next.  This means you can’t have two or more objects (text or bitmaps) side by side; the top boundary of each object must be no higher than the bottom of the preceding object.
  18863.  
  18864.     The last restriction is important.  If you violate it, you will not like the results.  However, if you want two or more bitmaps side by side, you can combine them into one before calling CopyBits to print the result.  Similarly, if you are just printing bitmaps you can rotate them yourself to achieve landscape printing.
  18865.  
  18866.  
  18867. NoDraftBits
  18868.  
  18869.     NoDraftBits (iOpCode = 7) is implemented on both the ImageWriter and the LaserWriter.  On the LaserWriter it does nothing, since the LaserWriter is always in draft mode and can always print bitmaps.  The format of the data block is the same as that for the DraftBits call.  This call cancels the effect of any preceding DraftBits call.  If there was no preceding DraftBits call, or the printer does not support draft-mode printing anyway, this call does nothing.
  18870. GetRotn
  18871.  
  18872.     GetRotn (iOpCode = 8) is implemented on the ImageWriter and LaserWriter.  Here is the format of the data block:
  18873.  
  18874.     TGetRotnBlk = RECORD        {data block for GetRotn call}
  18875.         iOpCode: Integer;       {input; = getRotnOp}
  18876.         iError: Integer;        {output}
  18877.         lReserved: LongInt;     {reserved for future use}
  18878.         hPrint: THPrint;        {input; handle to a valid print record}
  18879.         fLandscape: Boolean;    {output; Boolean flag}
  18880.         bXtra:  SignedByte;     {reserved}
  18881.     END;
  18882.  
  18883.     The hPrint parameter contains a handle to a print record that has previously been passed to PrValidate.
  18884.  
  18885.     If landscape orientation is selected in the print record, then fLandscape is true.
  18886.  
  18887. Using PrGeneral
  18888.     SetRsl and DraftBits calls may require the print code to suppress certain options in the Style and/or Job dialog boxes, therefore they should always be called before any call to the Style or Job dialogs.  An application might use PrGeneral as follows:
  18889.  
  18890. - Get a new print record by calling PrintDefault, or take an existing one from a document and call PrValidate on it.
  18891. - Call GetRslData to find out what the printer is capable of, and decide what resolution to use.  Check PrError to be sure the PrGeneral call is supported on this version of the print code; if the error is ResNotFound, you have older print code and must print accordingly.  But if the PrError return is 0, proceed as follows:
  18892. - Call SetRsl with the print record and the desired resolution if you wish.
  18893. - Call DraftBits to invoke the printing of bitmaps in draft mode if you wish.
  18894.  
  18895.     If you call either SetRsl or DraftBits, you should do so before the user sees either of the printing dialog boxes.
  18896. \ SetStylHandle
  18897. 8
  18898. Procedure SetStylHandle (theHandle: TEStyleHandle; hTE: TEHandle);
  18899.  
  18900.     The SetStylHandle procedure sets an edit record’s style handle, stored in the txFont and txFace fields.  SetStylHandle has no effect on an old-style edit record.  Applications should always use SetStylHandle rather than manipulating the fields of the edit record directly.
  18901. \ GetStylHandle
  18902. 8
  18903. Function  GetStylHandle (hTE: TEHandle) : TEStyleHandle;
  18904.  
  18905.     The GetStylHandle function gets an edit record’s style handle, stored in the txFont and txFace fields. GetStylHandle returns NIL when used with an old-style edit record. Applications should always use this function rather than manipulating the fields of the edit record directly.
  18906. \ GetStylScrap
  18907. 8
  18908. Function  GetStylScrap (hTE: TEHandle) : StScrpHandle;
  18909.  
  18910.     The GetStylScrap routine allocates a block of type StScrpRec and copies the style information associated with the current selection into it. This is the same as TECopy, except that no action is performed on the text, and the handle to the 'styl' scrap is output in this case. Unlike TECopy, the StScrpRec is not copied to the desk scrap.
  18911.     GetStylScrap will return a NIL value if called with an old style TEHandle, or if the selection is NIL (stylStart equals stylEnd).
  18912. \ TEStylInsert
  18913. 8
  18914. Procedure TEStylInsert (text: Ptr; length: LONGINT; hST: stScrpHandle; hTE: TEHandle);
  18915.  
  18916.     The TEStylInsert procedure takes the specified text and inserts it just before the selection range into the text indicated by hTE, redrawing the text as necessary. If hST is not NIL and hTE is a TextEdit record created using TEStylNew, the style information indicated by hST will also be inserted to correspond with the inserted text. When hST is NIL and/or hTE has not been created using TEStylNew, there is no difference between this procedure and TEInsert. TEStylInsert does not affect either the current selection range or the scrap.
  18917. \ TEGetOffset
  18918. 8
  18919. Function  TEGetOffset (pt: Point; hTE: TEHandle) : INTEGER;
  18920.  
  18921.     The TEGetOffset routine finds the character offset in an edit record’s text corresponding to the given point.  TEGetOffset works for both old-style and new-style edit records.
  18922. \ TEGetPoint
  18923. 8
  18924. Function TEGetPoint (offset: INTEGER; hTE: TEHandle) : POINT;
  18925.  
  18926.     The TEGetPoint routine returns the point corresponding to the given offset into the text. The point returned is to the bottom (baseline) left of the character at the specified offset. TEGetPoint works for both old- and new-style edit records.
  18927. \ TEGetHeight
  18928. 8
  18929. Function TEGetHeight (endLine, startLine: LONGINT; hTE: TEHandle) : INTEGER;
  18930.  
  18931.     The TEGetHeight routine returns the total height of all the lines in the text between and including startLine and endLine. TEGetHeight works for both old- and new-style edit records.
  18932. \ TEGetStyle
  18933. 8
  18934. Procedure TEGetStyle (offset: INTEGER; VAR theStyle: TextStyle;
  18935.                     VAR lineHeight,fontAscent: INTEGER; hTE: TEHandle);
  18936.  
  18937.     The TEGetStyle procedure returns the style information, including line height and font ascent, associated with a given character in an edit record’s text.  For an old-style edit record, it returns the record’s global text characteristics.
  18938. \ TEStylPaste
  18939. 8
  18940. Procedure TEStylPaste   (hTE: TEHandle);
  18941.  
  18942.     The TEStylPaste procedure pastes text from the desk scrap into the edit record’s text at the current insertion point or replaces the current selection.  The text is styled according to the style information found in the desk scrap; if there is none, it is given the same style as the first character of the replaced selection (or that of the preceding character if the selection is an insertion point).  In an old-style edit record, just the text is pasted without its accompanying style.
  18943. \ TESetStyle
  18944. 8
  18945. Procedure TESetStyle (mode: INTEGER; newStyle: TextStyle; redraw: BOOLEAN;  hTE: TEHandle);
  18946.  
  18947.     The TESetStyle procedure sets the style of the current selection to that specified by newStyle.  ( It has no effect on an old-style edit record.)  The mode parameter controls which style attributes to set; it may be any additive combination of the following constants:
  18948.  
  18949. CONST
  18950.    doFont  =  1;    {set font (family) number}
  18951.    doFace  =  2;    {set character style}
  18952.    doSize  =  4;    {set type size}
  18953.    doColor =  8;    {set color}
  18954.    doAll   = 15;    {set all attributes}
  18955.    addSize = 16;    {adjust type size}
  18956.  
  18957.     In the last case (addSize), the value of newStyle.tsSize is added to all type sizes within the current selection instead of replacing them; this value may be either positive or negative.  (If present, addSize overrides doSize.)  If redraw = TRUE, the affected text will be redrawn in the new style.
  18958. \ TEReplaceStyle
  18959. 8
  18960. Procedure TEReplaceStyle    (mode: INTEGER; oldStyle,newStyle: TextStyle; redraw: BOOLEAN; hTE: TEHandle);
  18961.  
  18962.     The TEReplaceStyle procedure replaces the style specified by oldStyle with that given by newStyle within the current selection.  (It has no effect on an old-style edit record.)  The mode parameter takes the same values as TESetStyle (above), except that addSize has no meaning here.  All styles for which the combination of attributes designated by mode have the values given by oldStyle are changed to have the corresponding values from newStyle instead.  Style changes are made directly to the style-table elements within the table itself.  If mode = doAll, newStyle simply replaces oldStyle outright.
  18963. \ InitCursorCtl
  18964. 32
  18965. Procedure InitCursorCtl(newCursors: UNIV AcurHandle);
  18966.  
  18967. Initialize the CursorCtl unit. This should be called once prior to calling RotateCursor or SpinCursor. It need not be called if only Hide_Cursor or Show_Cursor are used. If NewCursors is NULL, InitCursorCtl loads in the 'acur' resource and the 'CURS' resources specified by the 'acur' resource ids.  If any of the resources cannot be loaded, the cursor will not be changed.
  18968.  
  18969. The 'acur' resource is assumed to either be in the currently running tool or application, or the MPW Shell for a tool, or in the System file.  The 'acur' resource id must be 0 for a tool or application, 1 for the Shell, and 2 for the System file.
  18970.  
  18971. If NewCursors is not NULL, it is ASSUMED to be a handle to an 'acur' formatted resource designated by the caller and it will be used instead of doing a GetResource on 'acur'. Note, if RotateCursor or SpinCursor are called without calling InitCursorCtl, then RotateCursor and SpinCursor will do the call for the user the first time it is called.  However, the possible disadvantage of using this technique is that the resource memory allocated may have undesirable affect (fragmentation?) on the application. Using InitCursorCtl has the advantage of causing the allocation at a specific time determined by the user.
  18972.  
  18973. Caution: InitCursorCtl MODIFIES the 'acur' resource in memory.    Specifically, it changes each FrameN/fillN integer pair to a handle to the corresponding 'CURS' resource also in memory.  Thus if NewCursors is not NULL when InitCursorCtl is called, the caller must guarantee NewCursors always points to a "fresh" copy of an 'acur' resource.  This need only be of concern to a caller who wants to repeatly use multiple 'acur' resources during execution of their programs.
  18974. \ RotateCursor
  18975. 32
  18976. Procedure RotateCursor(counter: LONGINT);
  18977.  
  18978. RotateCursor is called to rotate the "I am active" "beach ball" cursor, or to animate whatever sequence of cursors set up by InitCursorCtl. The next cursor ("frame") is used when Counter % 32 = 0 (Counter is some kind of incrementing or decrementing index maintained by the caller). A positive counter sequences forward through the cursors (e.g., it rotates the "beach ball" cursor clockwise), and a negative cursor sequences through the cursors backwards (e.g., it rotates the "beach ball" cursor counterclockwise).  Note, RotateCursor just does a Mac SetCursor call for the proper cursor picture.
  18979.  
  18980. It is assumed the cursor is visible from a prior Show_Cursor call.
  18981. \ SpinCursor
  18982. 32
  18983. Procedure SpinCursor(increment: INTEGER);
  18984.  
  18985. SpinCursor is similar in function to RotateCursor, except that instead of passing a counter, an Increment is passed an added to a counter maintained here.  SpinCursor is provided for those users who do not happen to have a convenient counter handy but still want to use the spinning "beach ball" cursor, or any sequence of cursors set up by InitCursorCtl.  A positive increment sequences forward through the curos (rotating the "beach ball" cursor clockwise), and a negative increment sequences backward through the cursors (rotating the "beach ball" cursor counter-clockwise).  A zero value for the increment resets the counter to zero.  Note, it is the increment, and not the value of the counter that determines the sequencing direction of the cursor (and hence the spin direction of the "beach ball" cursor).\ Hide_Cursor
  18986. 32
  18987. Procedure Hide_Cursor;
  18988.  
  18989. Hide the cursor if it is showing.This is this unit's call to the Mac HideCursor routine.Thus the Mac cursor level is decremented by one when this routine is called.\ Show_Cursor
  18990. 32
  18991. Procedure Show_Cursor(cursorKind: Cursors);
  18992.  
  18993. Increment the cursor level, which may have been decremented by Hide_Cursor, and display the specified cursor if the level becomes 0 (it is never incremented beyond 0).The CursorKind is the kind of cursor to show.  It is one of the values HIDDEN_CURSOR, I_BEAM_CURSOR, CROSS_CURSOR, PLUS_CURSOR, WATCH_CURSOR, and ARROW_CURSOR. Except for HIDDEN_CURSOR, a Mac SetCursor is done for the specified cursor prior to doing a ShowCursor.    HIDDEN_CURSOR just causes a ShowCursor call.  Note, ARROW_CURSOR will only work correctly if there is already a grafPort set up pointed to by 0(A5).
  18994. \ InitErrMgr
  18995. 33
  18996. Procedure InitErrMgr(toolErrFileName: Str255; sysErrFileName: Str255;
  18997.        showToolErrNbrs: BOOLEAN);
  18998.  
  18999.      ErrMgr initialization.This must be done before using any other ErrMgr routine.  Set showToolErrNbrs to true if you want all tool messages to contain the error number following the message text enclosed in parentheses (e.g., "<msg txt> ([OS] Error <n>)"; system error messages always contain the error number).  The toolErrFileName parameter is used to specify the name of a tool-specific error file, and should be the NULL or a null string if not used (or if the tool's data fork is to be used as the error file, see GetToolErrText for futher details). The sysErrFileName parameter is used to specify the name of a system error file, and should normally be the NULL or a null string, which causes the ErrMgr to look in the MPW Shell directory for "SysErrs.Err" (see GetSysErrText). 
  19000.  
  19001. \ CloseErrMgr
  19002. 33
  19003. Procedure CloseErrMgr;
  19004.  
  19005.     Ideally a CloseErrMgr should be done at the end of execution to make sure all files opened by the ErrMgr are closed.
  19006.     You can let normal program termination do the closing.  But if you are a purist...
  19007.  
  19008. \ GetToolErrText
  19009. 33
  19010. Procedure GetToolErrText(msgNbr: INTEGER; errInsert: Str255;
  19011.         errMsg: StringPtr);
  19012.  
  19013.     Get the error message text corresponding to tool error number errNbr from the tool error message file (whose name was specified in the InitErrMgr call).    The text of the message is returned in errMsg and the function returns a pointer to errMsg.  The maximum length of the message is limited to 254 characters.  If the message is to have an insert, then ErrInsert should be a pointer to it.    Otherwise it should be either be a null string or a NULL pointer.
  19014.  
  19015.     Inserts are indicated in error messages by specifying a '^' to indicate where the insert is to be placed.
  19016.  
  19017. Note, if a tool message filename was not specified to InitErrMgr, then the ErrMgr assumes the message file contained in the data fork of the tool calling the ErrMgr.  This name is contained in the Shell variable    {Command} and the value of that variable is used to open the error message file. *)
  19018.  
  19019. \ GetSysErrText
  19020. 33
  19021. Procedure GetSysErrText(msgNbr: INTEGER; errMsg: StringPtr);
  19022.  
  19023.      Get the error message text corresponding to system error number errNbr from the system error message file (whose name was specified in the InitErrMgr call).    The text of the message is returned in errMsg and the function returns a pointer to errMsg.  The maximum length of the message is limited to 254 characters.
  19024.  
  19025. Note, if a system message filename was not specified to InitErrMgr, then the ErrMgr assumes the message file contained in the file "SysErrs.Err".  This file is first accessed as "{ShellDirectory}SysErrs.Err" on the assumption that SysErrs.Err is kept in the same directory as the MPW Shell.  If the file cannot be opened, then an open is attempted on "SysErrs.Err" in the System Folder. 
  19026.  
  19027. \ AddErrInsert
  19028. 33
  19029. Procedure AddErrInsert(errInsert: Str255; errMsg: StringPtr);
  19030.  
  19031.     Add another insert to an error message string.This call is used when more than one insert is to be added to a message (because it contains more than one '^' character).\ InitGrf3D
  19032. 35
  19033. Procedure InitGrf3D(globalPtr: Ptr);
  19034.  
  19035. \ Open3DPort
  19036. 35
  19037. Procedure Open3DPort(port: Port3DPtr);
  19038.  
  19039. \ SetPort3D
  19040. 35
  19041. Procedure SetPort3D(port: Port3DPtr);
  19042.  
  19043. \ GetPort3D
  19044. 35
  19045. Procedure GetPort3D(VAR port: Port3DPtr);
  19046.  
  19047. \ MoveTo2D
  19048. 35
  19049. Procedure MoveTo2D(x, y: Fixed);
  19050.  
  19051. \ MoveTo3D
  19052. 35
  19053. Procedure MoveTo3D(x, y, z: Fixed);
  19054.  
  19055. \ LineTo2D
  19056. 35
  19057. Procedure LineTo2D(x, y: Fixed);
  19058.  
  19059. \ LineTo3D
  19060. 35
  19061. Procedure LineTo3D(x, y, z: Fixed);
  19062.  
  19063. \ Move2D
  19064. 35
  19065. Procedure Move2D(dx, dy: Fixed);
  19066.  
  19067. \ Move3D
  19068. 35
  19069. Procedure Move3D(dx, dy, dz: Fixed);
  19070.  
  19071. \ Line2D
  19072. 35
  19073. Procedure Line2D(dx, dy: Fixed);
  19074.  
  19075. \ Line3D
  19076. 35
  19077. Procedure Line3D(dx, dy, dz: Fixed);
  19078.  
  19079. \ ViewPort
  19080. 35
  19081. Procedure ViewPort(r: Rect);
  19082.  
  19083. \ LookAt
  19084. 35
  19085. Procedure LookAt(left, top, right, bottom: Fixed);
  19086.  
  19087. \ ViewAngle
  19088. 35
  19089. Procedure ViewAngle(angle: Fixed);
  19090.  
  19091. \ Identity
  19092. 35
  19093. Procedure Identity;
  19094.  
  19095. \ Scale
  19096. 35
  19097. Procedure Scale(xFactor, yFactor, zFactor: Fixed);
  19098.  
  19099. \ Translate
  19100. 35
  19101. Procedure Translate(dx, dy, dz: Fixed);
  19102.  
  19103. \ Pitch
  19104. 35
  19105. Procedure Pitch(xAngle: Fixed);
  19106.  
  19107. \ Yaw
  19108. 35
  19109. Procedure Yaw(yAngle: Fixed);
  19110.  
  19111. \ Roll
  19112. 35
  19113. Procedure Roll(zAngle: Fixed);
  19114.  
  19115. \ Skew
  19116. 35
  19117. Procedure Skew(zAngle: Fixed);
  19118.  
  19119. \ Transform
  19120. 35
  19121. Procedure Transform(src: Point3D; VAR dst: Point3D);
  19122.  
  19123. \ Clip3D
  19124. 35
  19125. Function Clip3D(src1, src2: Point3D; VAR dst1, dst2: Point): BOOLEAN;
  19126.  
  19127. \ SetPt3D
  19128. 35
  19129. Procedure SetPt3D(VAR pt3D: Point3D; x, y, z: Fixed);
  19130.  
  19131. \ SetPt2D
  19132. 35
  19133. Procedure SetPt2D(VAR pt2D: Point2D; x, y: Fixed);
  19134.  
  19135. \ InitPalettes
  19136. 37
  19137. Procedure InitPalettes;
  19138.  
  19139.     InitPalettes initializes the Palette Manager.  It searches for devices which support a Color Look-Up Table (CLUT) and initializes an internal data structure for each one.  This call is made by InitWindows and should not have to be made by your application.
  19140. \ NewPalette
  19141. 37
  19142. Function NewPalette (entries: INTEGER; srcColors: CTabHandle; srcUsage, srcTolerance: INTEGER) : PaletteHandle;
  19143.  
  19144.     NewPalette allocates a new Palette object which contains a table of colors with enough room for “entries” colors.  It fills the table with as many RGB values from srcColors as it has or as it can fit.  It sets the usage field of each color to srcUsage and the tolerance value of each color to srcTolerance.  If no color table is provided (srcColors = NIL) then all colors in the palette are set to black (red = $0000, green = $0000, blue = $0000 ).
  19145. \ GetNewPalette
  19146. 37
  19147. Function GetNewPalette (paletteID: INTEGER) : PaletteHandle;
  19148.  
  19149.     GetNewPalette fetches a Palette object from the Resource Manager and initializes it.  If you open a new color window with GetNewCWindow, this routine is called automatically with paletteID equal to the window’s resource ID.  A palette resource is identified by type 'pltt'.  A paletteID of 0 is reserved for the system palette resource which is used as the default palette for noncolor windows and color windows without assigned palettes.
  19150. \ DisposePalette
  19151. 37
  19152. Procedure DisposePalette (srcPalette: PaletteHandle);
  19153.  
  19154.     DisposePalette disposes of a Palette object.  If the palette has any entries allocated for animation on any display device, these entries are relinquished prior to deallocation of the object.
  19155. \ ActivatePalette
  19156. 37
  19157. Procedure ActivatePalette (srcWindow: WindowPtr);
  19158.  
  19159.     ActivatePalette is the routine called by the Window Manager when your window’s status changes:  for example, when it opens, closes, moves, or becomes frontmost.  You should call ActivatePalette after making changes to a palette with the utility routines described below.  Such changes do not take effect until the next call to ActivatePalette, thereby allowing you to make a series of palette changes without any immediate change in the color environment.
  19160.  
  19161.     If srcWindow is frontmost, ActivatePalette examines the information stored in the palette associated with srcWindow and attempts to provide the color environment described therein.  It determines a list of devices on which to render the palette by intersecting the port rect of the srcWindow with each device.  If the intersection is not empty, and if the device has a Color Look-Up Table (CLUT), then ActivatePalette checks to see if the color environment is sufficient.  If a change is required, ActivatePalette calls the Color Manager to reserve or modify the device’s color entries as required.  It then generates update events for all affected windows which desire color updates.
  19162. \ SetPalette
  19163. 37
  19164. Procedure SetPalette (dstWindow: WindowPtr; srcPalette: PaletteHandle; cUpdates: BOOLEAN);
  19165.     SetPalette changes the palette associated with dstWindow to srcPalette.  It also records whether the window wants to receive updates as a result of a change to its color environment.  If you want dstWindow to be updated whenever its color environment changes, set cUpdates to TRUE.
  19166. \ GetPalette
  19167. 37
  19168. Function GetPalette (srcWindow: WindowPtr) : PaletteHandle;
  19169.  
  19170.     GetPalette returns a handle to the palette associated with srcWindow.  If no palette is associated with srcWindow, or if srcWindow is not a color window, GetPalette returns NIL.
  19171. \ PmForeColor
  19172. 37
  19173. Procedure PmForeColor (dstEntry: INTEGER);
  19174.     PmForeColor sets the RGB and index forecolor fields of the current cGrafPort according to the palette entry of the current cGrafPort (window) corresponding to dstEntry.  For courteous and tolerant entries, this call performs an RGBForeColor using the RGB color of the palette entry.  For animating colors it will select the recorded device index previously reserved for animation (if still present) and install it in the cGrafPort.  The RGB forecolor field is set to the value from the palette entry.  For explicit colors PmForeColor places (dstEntry modulo (MaxIndex+1)) into the cGrafPort, where MaxIndex is the largest index available in a device’s CLUT.  When multiple devices are present with different depths, MaxIndex varies appropriately for each device.
  19175. \ PmBackColor
  19176. 37
  19177. Procedure PmBackColor (dstEntry: INTEGER);
  19178.     PmBackColor sets the RGB and index backcolor fields of the current cGrafPort according to the palette entry of the current cGrafPort (window) corresponding to dstEntry.  For courteous and tolerant entries, this call performs an RGBBackColor using the RGB color of the palette entry. For animating colors it will select the recorded device index previously reserved for animation (if still present) and install it in the cGrafPort.  The RGB backcolor field is set to the value from the palette entry.  For explicit colors PmBackColor places (dstEntry modulo (MaxIndex+1)) into the cGrafPort, where MaxIndex is the largest index available in a device’s color table.  When multiple devices are present with different depths, MaxIndex varies appropriately for each device.
  19179. \ AnimateEntry
  19180. 37
  19181. Procedure AnimateEntry (dstWindow: WindowPtr; dstEntry: INTEGER; srcRGB: RGBColor);
  19182.  
  19183.     AnimateEntry changes the RGB value of dstEntry in the palette associated with dstWindow to the color specified by srcRGB.  Each device for which an index has been reserved is immediately modified to contain the new value.  This is not considered to be a change to the device’s color environment since no other windows should be using the animated entry.  If the palette entry is not an animating color, or if the associated indexes are no longer reserved, no animation is performed.
  19184.  
  19185.     If you have blocked color updates in a window, by using SetPalette with CUpdates set to FALSE, you may observe undesired animation.  This will occur when ActivatePalette reserves device indexes for animation which are already used in the window.  Redrawing the window, which normally occurs as the result of a color update event, will remove any animating colors which do not belong to it.
  19186. \ AnimatePalette
  19187. 37
  19188. Procedure AnimatePalette (dstWindow: WindowPtr; srcCTab: CTabHandle; srcIndex,dstEntry,dstLength: INTEGER);
  19189.  
  19190.     AnimatePalette performs a function similar to AnimateEntry, but it acts upon a range of palette entries.  Beginning at srcIndex (which has a minimum value of 0), the next dstLength entries are copied from srcCTab to dstWindow’s palette, beginning at dstEntry.  If srcCTab is not sufficiently large to accommodate the request, as many entries are modified as possible and the remaining entries are left unchanged.
  19191. \ GetEntryColor
  19192. 37
  19193. Procedure GetEntryColor (srcPalette: PaletteHandle; srcEntry: INTEGER; VAR dstRGB: RGBColor);
  19194.  
  19195.     GetEntryColor allows your application to access the color of a palette entry.  The color may be modified by using the SetEntryColor routine described below.
  19196. \ SetEntryColor
  19197. 37
  19198. Procedure SetEntryColor (dstPalette: PaletteHandle; dstEntry: INTEGER; srcRGB: RGBColor);
  19199.  
  19200.     SetEntryColor provides a convenient way for your application to modify the color of a single palette entry.  When you perform a SetPaletteEntry, the entry is marked as having changed, but no change occurs in the color environment.  The change will be effected upon the next call to ActivatePalette.  Modified entries are marked such that the palette will be updated even though no update might be required by a change in the color environment.
  19201. \ GetEntryUsage
  19202. 37
  19203. Procedure GetEntryUsage (srcPalette: PaletteHandle; srcEntry: INTEGER; VAR dstUsage,dstTolerance: INTEGER);
  19204.  
  19205.     GetEntryUsage allows your application to access the usage fields of a palette entry, namely ciUsage and ciTolerance.  These fields may be modified by using the SetEntryUsage routine described below.
  19206. \ SetEntryUsage
  19207. 37
  19208. Procedure SetEntryUsage (dstPalette: PaletteHandle; dstEntry: INTEGER; srcUsage,srcTolerance: INTEGER);
  19209.  
  19210.     SetEntryUsage provides a convenient way for your application to modify the color of a single palette entry.  When you perform a SetEntryUsage, the entry is marked as having changed, but no change occurs in the color environment.  The change will be effected upon the next call to ActivatePalette.  Modified entries are marked such that the palette will be updated even though no update might be required by a change in the color environment.  If either myUsage or myTolerance are set to $FFFF (–1) they will not be changed.
  19211.  
  19212.     This call is provided to allow easy modifications to a palette created with NewPalette or modified by CTab2Palette.  In such cases the ciUsage and ciTolerance fields are homogeneous since only one value can be designated for each.  You will typically call SetEntryUsage after those calls in order to adjust and customize your palette.
  19213. \ CTab2Palette
  19214. 37
  19215. Procedure CTab2Palette (srcCTab: CTabHandle; dstPalette: PaletteHandle; srcUsage,srcTolerance: INTEGER);
  19216.  
  19217.     CTab2Palette is a convenience procedure which copies the fields from an existing ColorTable record into an existing Palette record.  If the records are not the same size then the Palette record is resized to match the number of entries in the ColorTable record.  If dstPalette has any entries allocated for animation on any display device, these entries are relinquished prior to copying the new colors.  If you wish to effect color table animation you can change the colors in a palette, and on corresponding devices, with the AnimateEntry and AnimatePalette routines described above.  Changes made to a palette by CTab2Palette don’t take effect until the next ActivatePalette is performed.  If either the color table handle or the palette handle are NIL, no operation is performed.
  19218. \ Palette2CTab
  19219. 37
  19220. Procedure Palette2CTab (srcPalette: PaletteHandle; dstCTab: CTabHandle);
  19221.  
  19222.     Palette2CTab is a convenience procedure which copies all of the colors from an existing Palette record into an existing ColorTable record.  If the records are not the same size then the ColorTable record is resized to match the number of entries in the Palette record.  If either the palette handle or the color table handle are NIL, no operation is performed.
  19223. \ InitPerf
  19224. 38
  19225. Function InitPerf (VAR thePerfGlobals: TP2PerfGlobals;
  19226.      timerCount, codeAndROMBucketSize: INTEGER;
  19227.      doROM, doAppCode: BOOLEAN;
  19228.      appCodeType: Str255;
  19229.      romID: INTEGER;
  19230.      romName: Str255;
  19231.      doRAM: BOOLEAN;
  19232.      ramLow, RAMHigh: LONGINT;
  19233.      ramBucketSize: INTEGER
  19234.      ): BOOLEAN;
  19235.  
  19236. Called once to set up performance monitoring.
  19237. \ TermPerf
  19238. 38
  19239. Procedure TermPerf (thePerfGlobals: TP2PerfGlobals);
  19240.  
  19241. if InitPerf succeeds then TermPerf must be called before terminating program.
  19242. \ PerfControl
  19243. 38
  19244. Function PerfControl (thePerfGlobals: TP2PerfGlobals;
  19245.   turnOn: BOOLEAN): BOOLEAN;
  19246.  
  19247. Call this this to turn on/off performance measure.
  19248.  
  19249. Returns previous state.
  19250. \ PerfDump
  19251. 38
  19252. Function PerfDump (thePerfGlobals: TP2PerfGlobals;
  19253.   reportFile: Str255; doHistogram:BOOLEAN;
  19254.   rptFileColumns: INTEGER Number of columns in the report file}
  19255.  ): INTEGEROSErr};
  19256.  
  19257. Call this to dump the performance statistics into a file.
  19258. \ CvtPC
  19259. 38
  19260. Function CvtPC (thePerfGlobals: TP2PerfGlobals; pc: LONGINT): LONGINT;
  19261. \ GetColor
  19262. 39
  19263. Function GetColor(where: Point; prompt: Str255; inColor: RGBColor; VAR outColor: RGBColor) : BOOLEAN;
  19264.  
  19265.     GetColor displays the Color Picker dialog box on the screen, with its top-left corner located at where. (The where Point should be on the main gDevice.)  If where = (0,0), the dialog box is positioned neatly on the screen, centered horizontally, and with one third of the empty space above the box, two thirds below, whatever the screen size.
  19266.  
  19267.     The prompt string is displayed in the upper-left corner of the dialog box.  InColor is the starting color, which the user may want for comparison, and is displayed immediately below the current output color (the one the user is picking).  OutColor is set to the last color value the user picked, if and only if the user clicks OK.   On entry, it is treated as undefined, so the output color sample originally matches the input.  While the color being picked may vary widely, the input color sample remains fixed, and clicking in the input sample resets the output color sample to match it.
  19268.  
  19269.     GetColor returns TRUE if the user exits via the OK button, or FALSE if the user cancels.
  19270.  
  19271. Assembly-language note:  the trap macro for the Color Picker Package is _Pack12. The routine selectors are as follows:
  19272.  
  19273.     Fix2SmallFract  EQU 1
  19274.     SmallFract2Fix  EQU 2
  19275.     CMY2RGB         EQU 3
  19276.     RGB2CMY         EQU 4
  19277.     HSL2RGB         EQU 5
  19278.     RGB2HSL         EQU 6
  19279.     HSV2RGB         EQU 7
  19280.     RGB2HSV         EQU 8
  19281.     GetColor        EQU 9
  19282.  
  19283. \ CMY2RGB
  19284. 39
  19285. Procedure  CMY2RGB (cColor: CMYColor; VAR rColor: RGBColor);
  19286. \ RGB2CMY
  19287. 39
  19288. Procedure  RGB2CMY (rColor: RGBColor; VAR cColor: CMYColor);
  19289. \ HSL2RGB
  19290. 39
  19291. Procedure  HSL2RGB (hColor: HSLColor; VAR rColor: RGBColor);
  19292. \ RGB2HSL
  19293. 39
  19294. Procedure  RGB2HSL (rColor: RGBColor; VAR hColor: HSLColor);
  19295. \ HSV2RGB
  19296. 39
  19297. Procedure  HSV2RGB (hColor: HSVColor; VAR rColor: RGBColor);
  19298. \ RGB2HSV
  19299. 39
  19300. Procedure  RGB2HSV (rColor: RGBColor; VAR hColor: HSVColor);
  19301. \ Fix2SmallFract
  19302. 39
  19303. Function Fix2SmallFract(f: Fixed): SmallFract;
  19304.  
  19305.     A SmallFract can represent a value between 0 and  65,535.  They can be assigned directly to and from INTEGERs.
  19306. \ SmallFract2Fix
  19307. 39
  19308. Function SmallFract2Fix(s: SmallFract): Fixed;
  19309.     A SmallFract can represent a value between 0 and  65,535.  They can be assigned directly to and from INTEGERs.
  19310. \ IEEEDefaultEnv
  19311. 40
  19312. Function IEEEDefaultEnv: Environment;
  19313.  
  19314. \ GetTrapVector
  19315. 40
  19316. Procedure GetTrapVector(VAR Traps: TrapVector);
  19317.  
  19318. \ SetTrapVector
  19319. 40
  19320. Procedure SetTrapVector(Traps: TrapVector);
  19321.  
  19322. \ X96toX80
  19323. 40
  19324. Function X96toX80(x: EXTENDED): Extended80;
  19325.  
  19326. \ X80toX96
  19327. 40
  19328. Function X80toX96(x: Extended80): EXTENDED;
  19329.  
  19330. \ Sin
  19331. 40
  19332. Function Sin(x: EXTENDED): EXTENDED;
  19333.  
  19334. \ Cos
  19335. 40
  19336. Function Cos(x: EXTENDED): EXTENDED;
  19337.  
  19338. \ ArcTan
  19339. 40
  19340. Function ArcTan(x: EXTENDED): EXTENDED;
  19341.  
  19342. \ Exp
  19343. 40
  19344. Function Exp(x: EXTENDED): EXTENDED;
  19345.  
  19346. \ Ln
  19347. 40
  19348. Function Ln(x: EXTENDED): EXTENDED;
  19349.  
  19350. \ Log2
  19351. 40
  19352. Function Log2(x: EXTENDED): EXTENDED;
  19353.  
  19354. \ Ln1
  19355. 40
  19356. Function Ln1(x: EXTENDED): EXTENDED;
  19357.  
  19358. \ Exp2
  19359. 40
  19360. Function Exp2(x: EXTENDED): EXTENDED;
  19361.  
  19362. \ Exp1
  19363. 40
  19364. Function Exp1(x: EXTENDED): EXTENDED;
  19365.  
  19366. \ Tan
  19367. 40
  19368. Function Tan(x: EXTENDED): EXTENDED;
  19369.  
  19370. \ GetHaltVector
  19371. 40
  19372. Function GetHaltVector: LONGINT;
  19373.  
  19374. \ SetHaltVector
  19375. 40
  19376. Procedure SetHaltVector(v: LONGINT);
  19377.  
  19378. \ X96toX80
  19379. 40
  19380. Function X96toX80(x: Extended96): EXTENDED;
  19381.  
  19382. \ X80toX96
  19383. 40
  19384. Function X80toX96(x: EXTENDED): Extended96;
  19385.  
  19386. \ Log2
  19387. 40
  19388. Function Log2(x: EXTENDED): EXTENDED;
  19389.  
  19390. \ Ln1
  19391. 40
  19392. Function Ln1(x: EXTENDED): EXTENDED;
  19393.  
  19394. \ Exp2
  19395. 40
  19396. Function Exp2(x: EXTENDED): EXTENDED;
  19397.  
  19398. \ Exp1
  19399. 40
  19400. Function Exp1(x: EXTENDED): EXTENDED;
  19401.  
  19402. \ Tan
  19403. 40
  19404. Function Tan(x: EXTENDED): EXTENDED;
  19405.  
  19406. \ Num2Integer
  19407. 40
  19408. Function Num2Integer(x: EXTENDED): INTEGER;
  19409.  
  19410. \ Num2Longint
  19411. 40
  19412. Function Num2Longint(x: EXTENDED): LONGINT;
  19413.  
  19414. \ Num2Real
  19415. 40
  19416. Function Num2Real(x: EXTENDED): real;
  19417.  
  19418. \ Num2Double
  19419. 40
  19420. Function Num2Double(x: EXTENDED): DOUBLE;
  19421.  
  19422. \ Num2Extended
  19423. 40
  19424. Function Num2Extended(x: EXTENDED): EXTENDED;
  19425.  
  19426. \ Num2Comp
  19427. 40
  19428. Function Num2Comp(x: EXTENDED): comp;
  19429.  
  19430. \ Num2Dec
  19431. 40
  19432. Procedure Num2Dec(f: DecForm; x: EXTENDED; VAR d: Decimal);
  19433.  
  19434. \ Dec2Num
  19435. 40
  19436. Function Dec2Num(d: Decimal): EXTENDED;
  19437.  
  19438. \ Num2Str
  19439. 40
  19440. Procedure Num2Str(f: DecForm; x: EXTENDED; VAR s: DecStr);
  19441.  
  19442. \ Str2Num
  19443. 40
  19444. Function Str2Num(s: DecStr): EXTENDED;
  19445.  
  19446. \ Str2Dec
  19447. 40
  19448. Procedure Str2Dec(s: DecStr; VAR Index: INTEGER; VAR d: Decimal;
  19449.      VAR ValidPrefix: BOOLEAN);
  19450.  
  19451. \ CStr2Dec
  19452. 40
  19453. Procedure CStr2Dec(s: CStrPtr; VAR Index: INTEGER; VAR d: Decimal;
  19454.       VAR ValidPrefix: BOOLEAN);
  19455.  
  19456. \ Dec2Str
  19457. 40
  19458. Procedure Dec2Str(f: DecForm; d: Decimal; VAR s: DecStr);
  19459.  
  19460. \ Remainder
  19461. 40
  19462. Function Remainder(x, y: EXTENDED; VAR quo: INTEGER): EXTENDED;
  19463.  
  19464. \ Rint
  19465. 40
  19466. Function Rint(x: EXTENDED): EXTENDED;
  19467.  
  19468. \ Scalb
  19469. 40
  19470. Function Scalb(n: INTEGER; x: EXTENDED): EXTENDED;
  19471.  
  19472. \ Logb
  19473. 40
  19474. Function Logb(x: EXTENDED): EXTENDED;
  19475.  
  19476. \ CopySign
  19477. 40
  19478. Function CopySign(x, y: EXTENDED): EXTENDED;
  19479.  
  19480. \ NextReal
  19481. 40
  19482. Function NextReal(x, y: real): real;
  19483.  
  19484. \ NextDouble
  19485. 40
  19486. Function NextDouble(x, y: DOUBLE): DOUBLE;
  19487.  
  19488. \ NextExtended
  19489. 40
  19490. Function NextExtended(x, y: EXTENDED): EXTENDED;
  19491.  
  19492. \ XpwrI
  19493. 40
  19494. Function XpwrI(x: EXTENDED; i: INTEGER): EXTENDED;
  19495.  
  19496. \ XpwrY
  19497. 40
  19498. Function XpwrY(x, y: EXTENDED): EXTENDED;
  19499.  
  19500. \ Compound
  19501. 40
  19502. Function Compound(r, n: EXTENDED): EXTENDED;
  19503.  
  19504. \ Annuity
  19505. 40
  19506. Function Annuity(r, n: EXTENDED): EXTENDED;
  19507.  
  19508. \ RandomX
  19509. 40
  19510. Function RandomX(VAR x: EXTENDED): EXTENDED;
  19511.  
  19512. \ ClassReal
  19513. 40
  19514. Function ClassReal(x: real): NumClass;
  19515.  
  19516. \ ClassDouble
  19517. 40
  19518. Function ClassDouble(x: DOUBLE): NumClass;
  19519.  
  19520. \ ClassComp
  19521. 40
  19522. Function ClassComp(x: comp): NumClass;
  19523.  
  19524. \ ClassExtended
  19525. 40
  19526. Function ClassExtended(x: EXTENDED): NumClass;
  19527.  
  19528. \ SignNum
  19529. 40
  19530. Function SignNum(x: EXTENDED): INTEGER;
  19531.  
  19532. \ NAN
  19533. 40
  19534. Function NAN(i: INTEGER): EXTENDED;
  19535.  
  19536. \ SetException
  19537. 40
  19538. Procedure SetException(e: Exception; b: BOOLEAN);
  19539.  
  19540. \ TestException
  19541. 40
  19542. Function TestException(e: Exception): BOOLEAN;
  19543.  
  19544. \ SetHalt
  19545. 40
  19546. Procedure SetHalt(e: Exception; b: BOOLEAN);
  19547.  
  19548. \ TestHalt
  19549. 40
  19550. Function TestHalt(e: Exception): BOOLEAN;
  19551.  
  19552. \ SetRound
  19553. 40
  19554. Procedure SetRound(r: RoundDir);
  19555.  
  19556. \ GetRound
  19557. 40
  19558. Function GetRound: RoundDir;
  19559.  
  19560. \ SetPrecision
  19561. 40
  19562. Procedure SetPrecision(p: RoundPre);
  19563.  
  19564. \ GetPrecision
  19565. 40
  19566. Function GetPrecision: RoundPre;
  19567.  
  19568. \ SetEnvironment
  19569. 40
  19570. Procedure SetEnvironment(e: Environment);
  19571.  
  19572. \ GetEnvironment
  19573. 40
  19574. Procedure GetEnvironment(VAR e: Environment);
  19575.  
  19576. \ ProcEntry
  19577. 40
  19578. Procedure ProcEntry(VAR e: Environment);
  19579.  
  19580. \ ProcExit
  19581. 40
  19582. Procedure ProcExit(e: Environment);
  19583.  
  19584. \ Relation
  19585. 40
  19586. Function Relation(x, y: EXTENDED): RelOp;
  19587. \ SCSIReset
  19588. 34
  19589. Function SCSIReset: OSErr;
  19590.  
  19591. \ SCSIGet
  19592. 34
  19593. Function SCSIGet: OSErr;
  19594.  
  19595. \ SCSISelect
  19596. 34
  19597. Function SCSISelect(targetID: INTEGER): OSErr;
  19598.  
  19599. \ SCSICmd
  19600. 34
  19601. Function SCSICmd(buffer: Ptr; count: INTEGER): OSErr;
  19602.  
  19603. \ SCSIRead
  19604. 34
  19605. Function SCSIRead(tibPtr: Ptr): OSErr;
  19606.  
  19607. \ SCSIRBlind
  19608. 34
  19609. Function SCSIRBlind(tibPtr: Ptr): OSErr;
  19610.  
  19611. \ SCSIWrite
  19612. 34
  19613. Function SCSIWrite(tibPtr: Ptr): OSErr;
  19614.  
  19615. \ SCSIWBlind
  19616. 34
  19617. Function SCSIWBlind(tibPtr: Ptr): OSErr;
  19618.  
  19619. \ SCSIComplete
  19620. 34
  19621. Function SCSIComplete(VAR stat, message: INTEGER; wait: LONGINT): OSErr;
  19622.  
  19623. \ SCSIStat
  19624. 34
  19625. Function SCSIStat: INTEGER;
  19626.  
  19627. \ SCSISelAtn
  19628. 34
  19629. Function SCSISelAtn(targetID: INTEGER): OSErr;
  19630.  
  19631.     SCSISelAtn is identical in function to SCSISelect except that it asserts the Attention line during selection, signaling that you want to send a message to the device.
  19632. \ SCSIMsgIn
  19633. 34
  19634. Function SCSIMsgIn(VAR message: INTEGER): OSErr;
  19635.  
  19636. \ SCSIMsgOut
  19637. 34
  19638. Function SCSIMsgOut(message: INTEGER): OSErr;
  19639.  
  19640. \ IEsigset
  19641. 41
  19642. Function IEsigset(sgMap: SignalMap; sigHdlr: UNIV SignalHandler):
  19643.  SignalHandler;
  19644. \ IEsighold
  19645. 41
  19646. Function IEsighold(sgMap: SignalMap):
  19647.  SignalMap;
  19648. \ IEsigrelease
  19649. 41
  19650. Procedure IEsigrelease(sgMap: SignalMap; prevMap: SignalMap);
  19651. \ IEsigpause
  19652. 41
  19653. Procedure IEsigpause(sgMap: SignalMap);
  19654. \ GetCVariant
  19655. 6
  19656. Function GetCVariant (theControl: ControlHandle) : INTEGER; [Macintosh Plus, Macintosh SE, and Macintosh II]
  19657.  
  19658.     The GetVariant function returns the variant control value for the control described by theControl. This value was formerly stored in the high four bits of the control defproc handle; for future compatibility, use the GetCVariant routine to access this value.
  19659. \ SetCtlColor
  19660. 6
  19661. Procedure SetCtlColor (theControl: ControlHandle; newColorTable: CCTabHandle); [Macintosh II]
  19662.  
  19663.     The SetCtlColor procedure sets or modifies a control’s color table.  If the control currently has no auxiliary control record, a new one is created with the given color table and added to the head of the auxiliary control list. If there is already an auxiliary record for the control, its color table is replaced by the contents of newColorTable.
  19664.  
  19665.     If newColorTable has the same contents as the default color table, the control’s existing auxiliary record and color table are removed from the auxiliary control list and deallocated.  If theControl = NIL, the operation modifies the default color table itself. If the control is visible, it will be redrawn by SetCtlColor using the new color table.
  19666. \ GetAuxCtl
  19667. 6
  19668. Function GetAuxCtl (theControl: ControlHandle; VAR acHndl: AuxCtlHndl) : BOOLEAN; [Macintosh II]
  19669.  
  19670.     The GetAuxCtl function returns a handle to a control’s color table:
  19671.  
  19672. - If the given control has its own color table, the function returns TRUE.
  19673. - If the control used the default color set, the function returns FALSE.
  19674. - If the control asked to receive the default color set (theControl = NIL), then the function returns TRUE.
  19675. \ cdev
  19676. 43
  19677. Function cdev(message, Item, numItems, CPanelID: INTEGER;
  19678.             VAR theEvent: EventRecord; cdevValue: LONGINT;
  19679.             CPDialog: DialogPtr) : LONGINT;
  19680.  
  19681. Field descriptions
  19682.  
  19683. message     A message number, from the list defined below, that allows the Control  Panel to tell the cdev what event has just taken place.
  19684. Item        For hitDev messages only: the dialog item number of the item that was hit.  Since the cdev’s DITL is appended to the Control Panel’s DITL, the number of items preceding the cdev’s must be subtracted to get a value that is meaningful to the cdev.  (See the hitDev message, described below.)
  19685. numItems    The number of items in the DITL, belonging to the Control Panel, that precede the cdev’s dialog items in the item list.
  19686. CPanelID    The base resource ID of the Control Panel driver.  This value is private to the Control Panel.
  19687. theEvent    For hit, null, activate, deactivate, and key events: the event record for the event that caused the message.  See the Toolbox Event Manager in Volume I for details of the EventRecord structure.
  19688. cdevValue   The value the cdev returned the last time it was called by the Control Panel, or a return message from the Control Panel.  When a cdev is initialized it typically allocates some storage for state information or other data it needs to run.  Since desk accessories in general and the Control Panel in particular—and therefore cdevs—cannot have global variables, the cdevValue, which is passed to the cdev for every message, is often used for storing data.  The cdevValue is also used by the Control Panel to communicate error handling action to the cdev.  See “Storage in a Cdev” and “Cdev Error Checking” later in this chapter.
  19689. CPDialog    The Control Panel DialogPtr.  This may be a color dialog on Macintoshes that support color windows.
  19690.  
  19691.     The function value returned will be one of three kinds.  The Control Panel’s initial call to a cdev will be a macDev call, described below.  The cdev responds with a function value that tells the Control Panel whether the cdev should be displayed or not. In subsequent calls the cdev function result may be an error code, or data that needs to be kept until the Control Panel’s next call.  The function result is generally passed back to the cdev in the cdevValue parameter at the next cdev function call.
  19692.  
  19693.     The cdev will be called with the current resource file set to the cdev file, the current grafPort set to the Control Panel’s dialog, and the default volume set to the System Folder of the current startup disk.  The cdev must preserve all of these.  Also note that the Control Panel sets the cursor to the cross cursor whenever it is above the cdev area of the Control Panel window.  Your cdev thus has control of the cursor only during the call; if you change it, the Control Panel will immediately reset it.
  19694.  
  19695.     Your cdev may be reentered, especially if you put up dialog or alert boxes.  The Dialog Manager calls SystemEvent and SystemTask, which may cause a deactivate message to be sent while your cdev is still processing the previous message.
  19696.  
  19697. Messages
  19698.     The following cdev message values have been defined:
  19699. CONST
  19700.     initDev     = 0;    {initialization}
  19701.     hitDev      = 1;    {user clicked dialog item}
  19702.     closeDev    = 2;    {user selected another cdev or CP closed}
  19703.     nulDev      = 3;    {desk accessory run}
  19704.     updateDev   = 4;    {update event}
  19705.     activDev    = 5;    {activate event}
  19706.     deActivDev  = 6;    {deactivate event}
  19707.     keyEvtDev   = 7;    {key-down or auto-key event}
  19708.     macDev      = 8;    {check machine characteristics}
  19709.     undoDev     = 9;    {standard Edit menu undo}
  19710.     cutDev      =10;    {standard Edit menu cut}
  19711.     copyDev     =11;    {standard Edit menu copy}
  19712.     pasteDev    =12;    {standard Edit menu paste}
  19713.     clearDev    =13;    {standard Edit menu clear}
  19714.  
  19715.     The messages are described below.
  19716.  
  19717.     Before dispatching to handle a specific message, all cdevs should have some common defensive behavior, for example ensuring that they have enough memory to run.  Public-minded cdevs keep a minimum of memory allocated between calls, and memory that was free may be consumed by other applications while Control Panel is inactive, so it is important to check that there is enough memory available on every message.
  19718.  
  19719.     As part of their memory check, cdevs that depend on various Toolbox packages should ensure that there’s still room to load them.  Cdevs should also ignore any messages (except macDev) received before initialization, or after shutdown or an error.
  19720.  
  19721.     Your cdev, as part of a desk accessory that may move from one invocation to another, cannot use global variables.  This in turn means that you cannot set user item procedures for drawing user items in the 'DITL', because the procedure pointers will dangle if the code moves.  Instead, you must draw your user items in response to update messages.   Also, you must find Quickdraw globals by means of thePort if you need to reference them.
  19722.  
  19723.     See the sample cdev for examples.
  19724.  
  19725. The macDev Message
  19726.  
  19727.     If the 'mach' resource has a 0 in Softmask and a –1 ($FFFF) in Hardmask, the first message a cdev will get is a macDev message.  This is an opportunity for the cdev to determine whether it can run, and whether it should appear in the Control Panel’s cdev list.  The cdev can do its own check to see which machine it is being run on, what hardware is connected, and what is in the slots (if it has slots).  The cdev must then return a function result of 1 or 0.  If  a 0 is returned, the Control Panel will not display the cdev in the icon list.  (Note that the Control Panel does not interpret this 0 or 1 as an error message as described under “Cdev Error Checking”.)
  19728.  
  19729.     The macDev call happens only once, and only when Softmask and Hardmask are 0 and FFFF.  It is always the first call made to the cdev.
  19730.  
  19731. The initDev Message
  19732.  
  19733.     InitDev is an initialization message sent to allow the cdev to allocate its private storage (if any) and do any initial settings to buttons or controls.  This message is sent when the user clicks on the cdev’s icon.
  19734.  
  19735.     Note that the dialog, cdev list, and all of the items in the cdev’s 'DITL' except user items will already have been drawn when the initDev message is sent.
  19736.  
  19737.     If your cdev doesn’t need any storage it should return the value that was passed to it in cdevValue.
  19738.  
  19739. The activDev Message
  19740.  
  19741.     An activDev message is sent to the cdev on every activate event.  It allows the cdev to reset any items that may have changed while the Control Panel was inactive.   It also allows the cdev to send things such as “lists activate” messages.
  19742.  
  19743. The updateDev Message
  19744.  
  19745.     An updateDev message is sent to the cdev on every update event.  It allows the cdev to perform any updating necessary aside from the standard dialog item updating provided by the Dialog Manager.  For example, if the cdev resource contains a picture of the sound control bar, it will probably be a user item, and the picture of the control bar and the volume knob should be redrawn in response to update events.
  19746.  
  19747.     Note that there is no mechanism for determining what to update, as the update region has already been reset.  You must redraw all of your user items completely.
  19748.  
  19749. The nulDev Message
  19750.  
  19751.     A nulDev message is sent to the cdev on every Control Panel run event.  This allows the cdev to perform tasks that need to be executed continuously (insertion point blinking, for example).
  19752.  
  19753.     A cdev cannot assume any particular timing of calls from applications.  Don’t use nulDev to refresh settings; see activDev, above.
  19754.  
  19755. The hitDev Message
  19756.  
  19757.     A hitDev message is sent when the user has clicked an enabled dialog item that belongs to the cdev.  The dialog item number of the item hit is passed in the Item parameter.  Remember that the Control Panel’s items precede yours, so you’ll want (Item – numItems) to determine which of your items was hit.  If the Control Panel itself has n items, the first of the cdev’s items will be n+1 in the combined dialog item list.  A cdev should not depend on any hardcoded value for numItems, since the number of items in Control Panel’s 'DITL' is likely to change in the future.
  19758.  
  19759.     Factoring in numItems need not mean an increase in your code size, or passing and adding numItems everywhere, or foregoing the constants that most developers use to identify specific items.  You can do it easily, and neatly, as follows:
  19760.  
  19761.     1.  Subtract numItems from Item right away, and refer to your dialog items with constants as usual throughout the cdev.
  19762.  
  19763.     2.  Write simple envelope routines to enclose Dialog Manager procedures that require item number arguments.  Add numItems only locally, within those routines and for the Dialog Manager calls only.
  19764.  
  19765.     This is demonstrated in the sample cdev.
  19766.  
  19767. The keyEvtDev Message
  19768.  
  19769.     A keyEvtDev message is sent to the cdev on every keyDown event and autoKey event.  It allows the cdev to process key events.  On return to the Control Panel, the key event will be processed by a call to dialogSelect in the Dialog Manager.  A cdev that does not want the Toolbox Event Manager to do any further processing should change the what field of the EventRecord to nullEvent before returning to the Control Panel.
  19770.  
  19771. The deActivDev Message
  19772.  
  19773.     A deActivDev message is sent to the cdev on every deactivate event.  It allows the cdev to send deactivate messages to items such as lists.
  19774.  
  19775. The closeDev Message
  19776.  
  19777.     A closeDev message is sent to the cdev when either the Control Panel is closed or the user selects another cdev.  When a cdev receives a closeDev message it should dispose of any storage it has allocated, including the handle stored in cdevValue, if any.
  19778.  
  19779. The Standard Edit Menu Messages
  19780.  
  19781.     Values 9 through 13 have been defined in order to provide the standard Edit menu functions of Undo, Cut, Copy, Paste, and Clear for applications that need to implement them.
  19782.  
  19783. STORAGE IN A CDEV
  19784.  
  19785.     Since normal global storage is not available, the Control Panel, like all desk accessories, uses a special mechanism to store values between calls.  The cdevValue parameter in the cdev call extends this storage mechanism to cdevs.
  19786.  
  19787.     If a cdev needs to store information between calls it should create a handle during the initDev call, and return it as the cdev function result.  The Control Panel always returns such handles in the cdevValue parameter at the next call.
  19788.  
  19789.     If the cdev is called with a closeDev message, or if it needs to shut down because of an error, then this handle and any pointers or handles within the storage area should be disposed of before returning to the Control Panel.
  19790.  
  19791. CDEV ERROR CHECKING
  19792.  
  19793.     Because a desk accessory may be called into many strange and wonderful situations, careful attention must be paid to error checking.  The two most common error conditions are missing resources and lack of memory.  Some error reporting and recovery facilities have been provided in the Control Panel to help with errors encountered in a cdev.
  19794.  
  19795.     Because the Control Panel has no direct information about the cdev, the cdev’s code must be able to detect and recover from error conditions on its own.  If the recovery cannot be effected the cdev must dispose of any memory it has allocated, and exit back to the Control Panel with an error code.
  19796.  
  19797.     Following a shutdown, the Control Panel can help report the error condition to the user and prevent accidental reentry into the cdev that might result from such things as an update event.  A cdev can request three different error reporting mechanisms from the Control Panel:
  19798.  
  19799. - If a memory error has occured, then, after the cdev has safely shut itself down, it may request the Control Panel to issue an out-of-memory error message and gray out (paint over with the background pattern) the cdev area of the Control Panel window.  It will remain grayed until another cdev is selected.  The Control Panel window itself is not closed since other cdevs may still be able to function in the environment.
  19800. - If a resource error is detected, the cdev may request that a can’t-find-needed-resource error message be issued.
  19801. - The cdev may display its own error message and then call on the Control Panel to gray its area.
  19802.  
  19803.     The Control Panel uses the cdevValue parameter to send status information to the cdev, and a proper cdev uses its function value to send information back to the Control Panel.  In the absence of errors, the same value passes back and forth: the Control Panel puts the last function value it received into cdevValue when it calls the cdev; the cdev returns the value it finds there as the function value.  The cdev may want to keep a handle to its own storage, in which case passing it as the function value ensures its availability, since the Control Panel will pass it back in cdevValue at the next call.
  19804.  
  19805.     Four constants have been defined for this cdev/Control Panel communication:
  19806.  
  19807. CONST
  19808.     cdevUnset   =   3;  {initial value passed in cdevValue}
  19809.     cdevGenErr  =  -1;  {generic cdev error}
  19810.     cdevMemErr  =   0;  {insufficient memory for cdev execution}
  19811.     cdevResErr  =   1;  {missing resource needed by cdev}
  19812.  
  19813.     After the macDev call, the Control Panel sends cdevUnset in cdevValue, so that until an error occurs or the cdev uses its function value as a handle, cdevUnset is passed back and forth.  If the cdev encounters an error, it should dispose of all handles and pointers it has set up, strip the stack back to the same position as a normal exit, and return one of the three error codes as the function result.  The Control Panel will respond as follows:
  19814.  
  19815.     The cdev code should check cdevValue at entry.  A 0 means that the Control Panel has responded to a cdev error message by shutting down the cdev and displaying an error dialog if one was requested.  The cdev should immediately exit.
  19816.  
  19817.     Once the Control Panel has responded to an error message from a cdev it will no longer respond to any return values until another cdev is launched.
  19818. \ Sample
  19819. 43
  19820. UNIT cdev;
  19821.  
  19822. INTERFACE
  19823.  
  19824. USES
  19825.     MemTypes, QuickDraw, OSIntf, ToolIntf, PackIntf;
  19826.  
  19827. Function Sample (message, item, numItems, CPanelID: INTEGER;
  19828.                 theEvent: EventRecord; cdevValue: LONGINT;
  19829.                 CPDialog: DialogPtr) : LONGINT;
  19830.  
  19831. IMPLEMENTATION
  19832.  
  19833. CONST
  19834.     { Constants for all of Sample's dialog items }
  19835.     iVersion =      1;      {cdev's version number is just }
  19836.                             { staticText}
  19837.     iTitle =        2;      {title for Sample is just }
  19838.                             { staticText}
  19839.     iShowCounts =   3;      {show the events handled/ignored}
  19840.     iHideCounts =   4;      {hide the events handled/ignored}
  19841.     iTitleHandled = 5;      {title for events handled count}
  19842.     iTitleIgnored = 6;      {title for events ignored count}
  19843.     iHandled =      7;      {user item for number of events }
  19844.                             { handled}
  19845.     iIgnored =      8;      {user item for number of events }
  19846.                             { ignored}
  19847.  
  19848. TYPE
  19849.     SampleStorage = RECORD
  19850.         dlgPtr:     DialogPtr;
  19851.         dlgItems:   INTEGER;
  19852.         countShown: BOOLEAN;
  19853.         msgHandled: INTEGER;
  19854.         msgIgnored: INTEGER;
  19855.         END;
  19856.     SamplePtr = ^SampleStorage;
  19857.     SampleHdl = ^SamplePtr;
  19858.  
  19859. Function  InitSample (CPDialog: DialogPtr;
  19860.     numItems: INTEGER): LONGINT; FORWARD;
  19861. Function  EnoughRoomToRun (VAR cdevValue: LONGINT) : BOOLEAN; FORWARD;
  19862. Procedure CountMessage (ourHandle: SampleHdl; handledIt: BOOLEAN); FORWARD;
  19863. Procedure HitSample (ourHandle: SampleHdl; item: INTEGER); FORWARD;
  19864. Procedure DrawSampleItem (ourHandle: SampleHdl; item: INTEGER); FORWARD;
  19865. Function  IGetCtlHand (ourHandle: SampleHdl;
  19866.                  item: INTEGER): ControlHandle; FORWARD;
  19867. Procedure IGetRect (ourHandle: SampleHdl; item: INTEGER;
  19868.               VAR itemRect: Rect); FORWARD;
  19869. Procedure IHide (ourHandle: SampleHdl; item: INTEGER); FORWARD;
  19870. Procedure IShow (ourHandle: SampleHdl; item: INTEGER); FORWARD;
  19871. Procedure IInvalidate (ourHandle: SampleHdl; item: INTEGER); FORWARD;
  19872.  
  19873. {---------------------------------------------------------------------}
  19874. {Sample: the cdev dispatch function, as documented above.  The cdev   }
  19875. { function MUST be the first code in the code resource; Control Panel }
  19876. { jumps to the first location in the 'cdev' code resource to dispatch }
  19877. { messages to the cdev. }
  19878.  
  19879. Function Sample (message, item, numItems, CPanelID: INTEGER;
  19880.                 theEvent: EventRecord; cdevValue: LONGINT;
  19881.                 CPDialog: DialogPtr) : LONGINT;
  19882.  
  19883. VAR
  19884.     i: INTEGER;
  19885.     handledIt: BOOLEAN;
  19886.     ourHandle: SampleHdl;
  19887.     storageExpected: BOOLEAN;
  19888.  
  19889. BEGIN
  19890.     {Do a validity check before trying to handle the message. }
  19891.     { cdevValue is initialized to cdevUnset by Control Panel; zero }
  19892.     { is the new cdevValue after any error return.}
  19893.     storageExpected := NOT ((message = initDev)
  19894.         OR (message = macDev));
  19895.     IF storageExpected AND ((cdevValue = 0)
  19896.         OR (cdevValue = cdevUnset))
  19897.         THEN    cdevValue := 0
  19898.     {Equally important, we must check that there's still enough }
  19899.     { memory available for Sample to run, on every message. Memory }
  19900.     { can easily be consumed by other apps, etc, between messages, }
  19901.     { and (to be neighborly) we don't keep anything around between }
  19902.     { messages  except the handle in cdevValue.}
  19903.     ELSE IF storageExpected & NOT EnoughRoomToRun (cdevValue) THEN
  19904.         BEGIN
  19905.         {We're past initialization, and have been hit with a memory }
  19906.         { squeeze. Escape now, averting mayhem.}
  19907.         END
  19908.  
  19909.     ELSE
  19910.         BEGIN
  19911.         handledIt := TRUE;
  19912.         ourHandle := SampleHdl (cdevValue);
  19913.         CASE message OF
  19914.             initDev:    IF EnoughRoomToRun (cdevValue) THEN
  19915.                             BEGIN
  19916.                             cdevValue := InitSample
  19917.                                 (CPDialog, numItems);
  19918.                             ourHandle := SampleHdl
  19919.                                 (cdevValue);
  19920.                             END;
  19921.             closeDev:   IF ourHandle <> NIL THEN
  19922.                             BEGIN
  19923.                             DisposHandle (Handle
  19924.                                 (ourHandle));
  19925.                             cdevValue := 0;
  19926.                             ourHandle := NIL;
  19927.                             END;
  19928.             hitDev: HitSample (ourHandle, item - numItems);
  19929.             updateDev:  FOR i := iHandled TO iIgnored DO
  19930.                             DrawSampleItem (ourHandle, i);
  19931.             OTHERWISE   handledIt := FALSE;
  19932.             END;
  19933.             IF ourHandle <> NIL THEN
  19934.             CountMessage(ourHandle, handledIt);
  19935.             END;
  19936.  
  19937.     Sample := cdevValue;
  19938. END;
  19939.  
  19940. {----------------------------------------------------------------------}
  19941. {InitSample: Initialize the cdev}
  19942.  
  19943. Function InitSample (CPDialog: DialogPtr; numItems: INTEGER): LONGINT;
  19944. VAR
  19945.     i:      INTEGER;
  19946.     ourHandle:  SampleHdl;
  19947. BEGIN
  19948.     ourHandle := SampleHdl (NewHandle (SIZEOF (SampleStorage)));
  19949.     IF ourHandle <> NIL THEN
  19950.         BEGIN
  19951.         WITH ourHandle^^ DO
  19952.             BEGIN
  19953.             dlgPtr := CPDialog;
  19954.             dlgItems := numItems;
  19955.             msgHandled := 0;
  19956.             msgIgnored := 0;
  19957.             countShown := TRUE;
  19958.             END;
  19959.         FOR i := iShowCounts TO iHideCounts DO
  19960.             SetCtlValue (IGetCtlHand (ourHandle, i), ORD (i =
  19961.                         iShowCounts));
  19962.         END;
  19963.     InitSample := ORD4 (ourHandle);
  19964. END;
  19965.  
  19966. {----------------------------------------------------------------------}
  19967. {EnoughRoomToRun: check that we still have room to run; close up if not }
  19968.  
  19969. Function EnoughRoomToRun (VAR cdevValue: LONGINT) : BOOLEAN;
  19970. VAR
  19971.     error:  INTEGER;
  19972.     packHand:   Handle;
  19973. BEGIN
  19974.     {Make sure there is still room for the maximum amount of memory }
  19975.     { needed to process any event, AND for any packages or other }
  19976.     { resources you need at the same time.  If you allocate lots  of }
  19977.     { storage, you should account for that also if it hasn't  been }
  19978.     { allocated yet.  Sample needs the Binary/Decimal  conversion }
  19979.     { package to display the event counts. }
  19980.     { In the interest of simplicity, this does NOT take into account }
  19981.     { the fact that PACK 7 may be in ROM; it really should.}
  19982.     packHand := GetResource ('PACK', 7);
  19983.     IF packHand <> NIL THEN
  19984.         BEGIN
  19985.         EnoughRoomToRun := TRUE;
  19986.         EXIT (EnoughRoomToRun);
  19987.         END
  19988.     ELSE IF ResError = resNotFound
  19989.         THEN error := cdevResErr    {a needed resource is missing}
  19990.         ELSE error := cdevMemErr;   {assume memFull otherwise}
  19991.  
  19992.     {There's too little memory to load the package.  Try to fail }
  19993.     { gracefully, disposing of our storage if it's already been }
  19994.     { allocated, because the error code we return to Control Panel }
  19995.     { will replace cdevValue.}
  19996.     IF (cdevValue <> cdevUnset) AND (Handle (cdevValue) <> NIL) THEN
  19997.         DisposHandle (Handle (cdevValue));
  19998.     cdevValue := error;
  19999.     EnoughRoomToRun := FALSE;
  20000. END;
  20001.  
  20002. {----------------------------------------------------------------------}
  20003. {CountMessage: count message from Control Panel as handled/ignored}
  20004.  
  20005. Procedure CountMessage (ourHandle: SampleHdl; handledIt: BOOLEAN);
  20006. BEGIN
  20007.     IF ourHandle <> NIL THEN
  20008.         WITH ourHandle^^ DO
  20009.             IF handledIt THEN
  20010.                 BEGIN
  20011.                 msgHandled := msgHandled + 1;
  20012.                 DrawSampleItem (ourHandle, iHandled);
  20013.                 END
  20014.             ELSE
  20015.                 BEGIN
  20016.                 msgIgnored := msgIgnored + 1;
  20017.                 DrawSampleItem (ourHandle, iIgnored);
  20018.                 END
  20019. END;
  20020. {----------------------------------------------------------------------}
  20021. {HitSample: Handle a hit in one of our DITL items}
  20022.  
  20023. Procedure HitSample (ourHandle: SampleHdl; item: INTEGER);
  20024. VAR
  20025.     i:      INTEGER;
  20026. BEGIN
  20027.     WITH ourHandle^^ DO
  20028.         IF countShown <> (item = iShowCounts)
  20029.             THEN countShown := (item = iShowCounts)
  20030.             ELSE EXIT (HitSample);
  20031.  
  20032.     FOR i := iShowCounts TO iHideCounts DO
  20033.         SetCtlValue (IGetCtlHand (ourHandle, i), ORD (i = item));
  20034.     FOR i := iTitleHandled TO iIgnored DO
  20035.         BEGIN
  20036.         IF item = iShowCounts
  20037.             THEN IShow (ourHandle, i)
  20038.             ELSE IHide (ourHandle, i);
  20039.         IInvalidate (ourHandle, i);
  20040.         END;
  20041. END;
  20042.  
  20043. {----------------------------------------------------------------------}
  20044. {DrawSampleItem: Draw one of our DITL user items}
  20045.  
  20046. Procedure DrawSampleItem (ourHandle: SampleHdl; item: INTEGER);
  20047. VAR
  20048.     itemRect:   Rect;
  20049.     s:      Str255;
  20050. BEGIN
  20051.     {Note that Sample draws its user items explicitly, rather than }
  20052.     { installing a pointer to the draw procedure in the dialog item. }
  20053.     { Since the cdev's code may move between messages, the pointer }
  20054.     { would become invalid (Control Panel often calls the dialog }
  20055.     { manager before the cdev, so there's no chance to refresh the }
  20056.     { pointer either).}
  20057.     IGetRect (ourHandle, item, itemRect);
  20058.     WITH ourHandle^^ DO
  20059.         BEGIN
  20060.         SetPort (dlgPtr);
  20061.         IF item = iHandled
  20062.             THEN NumToString (msgHandled, s)
  20063.             ELSE NumToString (msgIgnored, s);
  20064.         END;
  20065.     WITH itemRect DO
  20066.         MoveTo (left, bottom);
  20067.     TextMode (srcCopy);
  20068.     DrawString (s);
  20069.     TextMode (srcOr);
  20070. END;
  20071.  
  20072. {----------------------------------------------------------------------}
  20073. {Simple routines enclosing the dialog manager functions we need, to}
  20074. { tack on numItems (so we can refer to our items with constants }
  20075. { everywhere else). }
  20076.  
  20077. {IGetCtlHand: get control handle for given dialog item}
  20078. {IGetRect: get rectangle for given dialog item}
  20079. {IHide: hide dialog item}
  20080. {IShow: show dialog item}
  20081. {IInvalidate: erase & invalidate dialog item}
  20082.  
  20083. Function IGetCtlHand (ourHandle: SampleHdl; item: INTEGER): ControlHandle;
  20084. VAR
  20085.     itemHand:   Handle;
  20086.     itemRect:   Rect;
  20087.     itemType:   INTEGER;
  20088. BEGIN
  20089.     WITH ourHandle^^ DO
  20090.         GetDItem (dlgPtr, item + dlgItems, itemType, itemHand,                      itemRect);
  20091.     IGetCtlHand := ControlHandle (itemHand);
  20092. END;
  20093.  
  20094. Procedure IGetRect (ourHandle: SampleHdl; item: INTEGER; VAR itemRect:                      Rect);
  20095. VAR
  20096.     itemType:   INTEGER;
  20097.     itemHand:   Handle;
  20098. BEGIN
  20099.     WITH ourHandle^^ DO
  20100.         GetDItem (dlgPtr, item + dlgItems, itemType, itemHand,                      itemRect);
  20101. END;
  20102.  
  20103. Procedure IHide (ourHandle: SampleHdl; item: INTEGER);
  20104. BEGIN
  20105.     WITH ourHandle^^ DO
  20106.         HideDItem (dlgPtr, item + dlgItems);
  20107. END;
  20108.  
  20109. Procedure IShow (ourHandle: SampleHdl; item: INTEGER);
  20110. BEGIN
  20111.     WITH ourHandle^^ DO
  20112.         ShowDItem (dlgPtr, item + dlgItems);
  20113. END;
  20114.  
  20115. Procedure IInvalidate (ourHandle: SampleHdl; item: INTEGER);
  20116. VAR
  20117.     itemRect:   Rect;
  20118. BEGIN
  20119.     IGetRect (ourHandle, item, itemRect);
  20120.     EraseRect (itemRect);
  20121.     InvalRect (itemRect);
  20122. END;
  20123.  
  20124. END.
  20125. \ PBHGetVolParms
  20126. 17
  20127. Function PBHGetVolParms (paramBlock:  HParmBlkPtr; async: BOOLEAN) :  OSErr;
  20128.  
  20129.     Trap macro  _GetVolParms
  20130.  
  20131. Parameter block
  20132.  
  20133. ——> 12  ioCompletion    long    optional completion routine ptr
  20134. <—— 16  ioResult        word    error result code
  20135. ——> 18  ioFileName      long    volume name specifier
  20136. ——> 22  ioVRefNum       word    volume refNum
  20137. <—— 32  ioBuffer        long    ptr to vol parms data
  20138. ——> 36  ioReqCount      long    size of buffer area
  20139. <—— 40  ioActCount      long    length of vol parms data
  20140.  
  20141.     The PBHGetVolParms call is used to return volume level information.  ioVRefNum or ioFileName contain the volume identifier information.  ioReqCount and ioBuffer contain the size and location of the buffer in which to place the volume parameters.  The actual size of the information is returned in ioActCount.
  20142.  
  20143.     The format of the buffer is described below.  Version 01 of the buffer is shown below along with offsets into the buffer and their equates:
  20144.  
  20145. offset  0   vMVersion   word    version number (currently 01)
  20146.         2   vMAttrib    long    attributes (detailed below)
  20147.         6   vMLocalHand long    handle used to keep information necessary
  20148.                                 for shared volumes
  20149.         10  vMServerAdr long    AppleTalk server address (0 if not
  20150.                                 supported)
  20151.  
  20152.     On creation of the VCB (right after mounting), vMLocalHand will be a handle to a 2 byte block of memory.  The Finder uses this for its local window list storage, allocating and deallocating memory as needed.  It is disposed of when the volume is unmounted.
  20153.  
  20154.     For AppleTalk server volumes, vMServerAdr contains the AppleTalk internet address of the server.  This can be used to tell which volumes are for which server.
  20155.  
  20156.     vMAttrib contains attributes information (32 flag bits) about the volume.  These bits and their equates are defined as follows:
  20157.  
  20158. bit 31  bLimitFCBs  If set, Finder limits the number of FCBs used during
  20159.         copies to 8 (instead of 16).
  20160.     30  bLocalWList If set, Finder uses the returned shared volume handle
  20161.         for its local window list.
  20162.     29  bNoMiniFndr If set, Mini Finder menu item is disabled.
  20163.     28  bNoVNEdit   If set, volume name cannot be edited.
  20164.     27  bNoLclSync  If set, volume’s modification date is not set by any
  20165.         Finder action.
  20166. \ PBHGetLogInInfo
  20167. 17
  20168. Function PBHGetLogInInfo (paramBlock: HParmBlkPtr; async: BOOLEAN) : OSErr;
  20169.  
  20170.         Trap macro  _GetLogInInfo
  20171.  
  20172. Parameter block
  20173.  
  20174. ——> 12  ioCompletion    long    optional completion routine ptr
  20175. <—— 16  ioResult        word    error result code
  20176. ——> 22  ioVRefNum       word    volume refNum
  20177. <—— 26  ioObjType       word    log in method
  20178. <—— 28  ioObjNamePtr    long    ptr to log in name buffer
  20179.  
  20180. PBHGetLogInInfo returns the method used for log-in and the user name specified at log-in time for the volume.  The log-in user name is returned as a Pascal string in ioObjNamePtr.  The maximum size of the user name is 31 characters.  The log-in method type is returned in ioObjType.
  20181. \ PBHGetDirAccess
  20182. 17
  20183. Function PBHGetDirAccess (paramBlock: HParmBlkPtr; async: BOOLEAN): OSErr;
  20184.  
  20185.         Trap macro  _GetDirAccess
  20186.  
  20187. Parameter block
  20188.  
  20189. ——> 12  ioCompletion    long    optional completion routine ptr
  20190. <—— 16  ioResult        word    error result code
  20191. ——> 18  ioFileName      long    directory name
  20192. ——> 22  ioVRefNum       word    volume refNum
  20193. <—— 36  ioACOwnerID     long    owner ID
  20194. <—— 40  ioACGroupID     long    group ID
  20195. <—— 44  ioACAccess      long    access rights
  20196. ——> 48  ioDirID long    directory ID
  20197.  
  20198.     PBHGetDirAccess returns access control information for the folder pointed to by the ioDirID/ioFIleName pair.  ioACOwnerID will return the ID for the folder’s owner.  ioACGroupID will return the ID for the folder’s primary group.  The access rights are returned in ioACAccess.
  20199.  
  20200.     A fnfErr is returned if the pathname does not point to a valid directory.  An AccessDenied error is returned if the user does not have the correct access rights to examine this directory.
  20201. \ PBHSetDirAccess
  20202. 17
  20203. Function PBHSetDirAccess (paramBlock: HParmBlkPtr; async: BOOLEAN) : OSErr;
  20204.  
  20205.         Trap macro  _SetDirAccess
  20206.  
  20207. Parameter block
  20208.  
  20209. ——> 12  ioCompletion    long    optional completion routine ptr
  20210. <—— 16  ioResult        word    error result code
  20211. ——> 18  ioFileName      long    pathname identifier
  20212. ——> 22  ioVRefNum       word    volume refNum
  20213. ——> 36  ioACOwnerID     long    owner ID
  20214. ——> 40  ioACGroupID     long    group ID
  20215. ——> 44  ioACAccess      long    access rights
  20216. ——> 48  ioDirID         long    directory ID
  20217.  
  20218.     PBHSetDirAccess allows you to change the access rights to a folder pointed to by the ioFileName/ioDirID pair.  IOACOwnerID contains the new owner ID.  IOACGroupID contains the group ID.  IOACAccess contains the folder’s access rights.  You cannot set the owner bit or the user’s rights of the directory.  To change the owner or group, you should set the ioACOwnerID or ioACGroupID field with the appropriate ID of the new owner/group.  You must be the owner of the directory to change the owner or group ID.
  20219.  
  20220.     A fnfErr is returned if the pathname does not point to a valid directory.  An AccessDenied error is returned if you do not have the correct access rights to modify the parameters for this directory.  A paramErr is returned if you try to set the owner bit or user’s rights bits.
  20221. \ PBHMapID
  20222. 17
  20223. Function PBHMapID (paramBlock: HParmBlkPtr; async: BOOLEAN): OSErr;
  20224.  
  20225.         Trap macro  _MapID
  20226.  
  20227. Parameter block
  20228.  
  20229. ——> 12  ioCompletion    long    optional completion routine ptr
  20230. <—— 16  ioResult        word    error result code
  20231. ——> 18  ioFileName      long    pathname identifier
  20232. ——> 22  ioVRefNum       word    volume refNum
  20233. ——> 26  ioObjType       word    function code
  20234. <—— 28  ioObjNamePtr    long    ptr to retrnd creator/group name
  20235. ——> 32  ioObjID long    creator/group ID
  20236.  
  20237.     PBHMapID returns the name of a user or group given its unique ID.  IOObjID contains the ID to be mapped.  The value zero for ioObjID is special cased and will always return a NIL name.  AppleShare uses this to signify <Any User>.  IOObjType is the mapping function code; it’s 1 if you’re mapping an owner ID to owner name or 2 if you’re mapping a group ID to a group name.  The name is returned as a Pascal string in ioObjNamePtr.  The maximum size of the name is 31 characters.
  20238.  
  20239.     A fnfErr is returned if an unrecognizable owner or group ID is passed.
  20240. \ PBHMapName
  20241. 17
  20242. Function PBHMapName(paramBlock: HParmBlkPtr; async: BOOLEAN) : OSErr;
  20243.  
  20244.         Trap macro  _MapName
  20245.  
  20246. Parameter block
  20247.  
  20248. ——> 12  ioCompletion    long    optional completion routine ptr
  20249. <—— 16  ioResult        word    error result code
  20250. ——> 18  ioFileName      long    volume identifier (may be NIL)
  20251. ——> 22  ioVRefNum       word    volume refNum
  20252. ——> 28  ioObjNamePtr    long    owner or group name
  20253. ——> 26  ioObjType       word    function code
  20254. <—— 32  ioObjID long    creator/group ID
  20255.  
  20256.     PBHMapName returns the unique user ID or group ID given its name.  The name is passed as a string in ioObjNamePtr.  If a NIL name is passed, the ID returned will always be zero.  The maximum size of the name is 31 characters.  IOObjType is the mapping function code; it’s 3 if you’re mapping an owner name to owner ID or 4 if you’re mapping a group name to a group ID.  IOObjID will contain the mapped ID.
  20257.  
  20258.     A fnfErr is returned if an unrecognizable owner or group name is passed.
  20259. \ PBHCopyFile
  20260. 17
  20261. Function PBHCopyFile (paramBlock: HParmBlkPtr; async: BOOLEAN) : OSErr;
  20262.  
  20263.         Trap macro  _CopyFile
  20264.  
  20265. Parameter block
  20266.  
  20267. ——> 12  ioCompletion    long    optional completion routine ptr
  20268. <—— 16  ioResult        word    error result code
  20269. ——> 18  ioFileName      long    ptr to source pathname
  20270. ——> 22  ioVRefNum       word    source vol identifier
  20271. ——> 24  ioDstVRefNum    word    destination vol identifier
  20272. ——> 28  ioNewName       long    ptr to destination pathname
  20273. ——> 32  ioCopyName      long    ptr to optional name (may be NIL)
  20274. ——> 36  ioNewDirID      long    destination directory ID
  20275. ——> 48  ioDirID         long    source directory ID
  20276.  
  20277.     PBHCopyFile duplicates a file on the volume and optionally renames it.  It is an optional call for AppleShare file servers.  You should examine the returned flag information in the PBHGetVolParms call to see if this volume supports CopyFile.
  20278.  
  20279.     For AppleShare file servers, the source and destination pathnames must indicate the same file server; however, it may point to a different volume for that file server.  A useful way to tell if two file server volumes are on the same file server is to make the GetVolParms call and compare the server addresses returned.  The server will open source files with read/deny write enabled and destination files with write/deny read and write enabled.
  20280.  
  20281.     IOVRefNum contains a source volume identifier.  The source pathname is determined by the ioFileName/ioDirID pair.  IODstVRefNum contains a destination volume identifier.  AppleShare 1.0 required that it be an actual volume reference number; however, on future versions it can be a WDRefNum.  The destination pathname is determined by the ioNewName/ioNewDirID pair.  IOCopyName may contain an optional string used in renaming the file.  If it is non-NIL then the file copy will be renamed to the specified name in ioCopyName.
  20282.  
  20283.     A fnfErr is returned if the source pathname does not point to an existing file or the destination pathname does not point to an existing directory.  An AccessDenied error is returned if the user does not have the right to read the source or write to the destination.  A dupFnErr is returned if the destination already exists.  A DenyConflict error is returned if either the source or destination file could not be opened under the access modes described above.
  20284. \ PBHMoveRename
  20285. 17
  20286. Function PBHMoveRename (paramBlock: HParmBlkPtr; async: BOOLEAN) : OSErr;
  20287. Trap macro  _MoveRename
  20288.  
  20289. Parameter block
  20290.  
  20291. ——> 12  ioCompletion    long    optional completion routine ptr
  20292. <—— 16  ioResult        word    error result code
  20293. ——> 18  ioFileName      long    ptr to source pathname
  20294. ——> 22  ioVRefNum       word    source vol identifier
  20295. ——> 28  ioNewName       long    ptr to destination pathname
  20296. ——> 32  ioBuffer        long    ptr to optional name (may be NIL)
  20297. ——> 36  ioNewDirID      long    destination directory ID
  20298. ——> 48  ioDirID         long    source directory ID
  20299.  
  20300.     PBHMoveRename allows you to move (not copy) an item and optionally to rename it.  The source and destination pathnames must point to the same file server volume.
  20301.  
  20302.     IOVRefNum contains a source volume identifier.  The source pathname is specified by the ioFileName/ioDirID pair.  The destination pathname is specified by the ioNewName/
  20303.  
  20304.     ioNewDirID pair.  IOBuffer may contain an optional string used in renaming the item.  If it is non-NIL then the moved object will be renamed to the specified name in ioBuffer.
  20305.  
  20306.     A fnfErr is returned if the source pathname does not point to an existing object.  An AccessDenied error is returned if the user does not have the right to move the object.  A dupFnErr is returned if the destination already exists.  A badMovErr is returned if an attempt is made to move a directory into one of its descendent directories.
  20307. \ PBHOpenDeny
  20308. 17
  20309. Function PBHOpenDeny (paramBlock: HParmBlkPtr; async: BOOLEAN): OSErr;
  20310.  
  20311.         Trap macro  _OpenDeny
  20312.  
  20313. Parameter block
  20314.  
  20315. ——> 12  ioCompletion    long    optional completion routine ptr
  20316. <—— 16  ioResult        word    error result code
  20317. ——> 18  ioFileName      long    ptr to pathname
  20318. ——> 22  ioVRefNum       word    vol identifier
  20319. <—— 24  ioRefNum        word    file refNum
  20320. ——> 26  ioDenyModes     word    access rights data
  20321. ——> 48  ioDirID long    directory ID
  20322.  
  20323.     PBHOpenDeny opens a file’s data fork under specific access rights.  It creates an access path to the file having the name pointed to by ioFileName/ioDirID.  The path reference number is returned in ioRefNum.
  20324.  
  20325.     IODenyModes contains a word of access rights information.  The format for these access rights is:
  20326.     bits    15–6    Reserved—should be cleared.
  20327.             5       If set, other writers are denied access.
  20328.             4       If set, other readers are denied access.
  20329.             3–2     Reserved—should be cleared.
  20330.             1       If set, write permission requested.
  20331.             0       If set, read permission requested.
  20332.  
  20333.     A fnfErr is returned if the input specification does not point to an existing file.  A permErr is returned if the file is already open and you cannot open it under the deny modes that you have specified.  An opWrErr is returned if you have asked for write permission and the file is already opened by you for write.  The already opened path reference number is returned in ioRefNum.  An AccessDenied error is returned if you do not have the right to access the file.
  20334. \ PBHOpenRFDeny
  20335. 17
  20336. Function PBHOpenRFDeny (paramBlock: HParmBlkPtr; async: BOOLEAN) : OSErr;
  20337.  
  20338.         Trap macro  _OpenRFDeny
  20339.  
  20340. Parameter block
  20341.  
  20342. ——> 12  ioCompletion    long    optional completion routine ptr
  20343. <—— 16  ioResult    word    error result code
  20344. ——> 18  ioFileName  long    ptr to pathname
  20345. ——> 22  ioVRefNum   word    vol identifier
  20346. <—— 24  ioRefNum    word    file refNum
  20347. ——> 26  ioDenyModes word    access rights data
  20348. ——> 48  ioDirID long    directory ID
  20349.  
  20350.     PBHOpenRFDeny opens a file’s resource fork under specific access rights.  It creates an access path to the file having the name pointed to by ioFileName/ioDirID.  The path reference number is returned in ioRefNum.  The format of the access rights data contained in ioDenyModes is described under the OpenDeny call.
  20351.  
  20352.     A fnfErr is returned if the input specification does not point to an existing file.  A permErr is returned if the file is already open and you cannot open it under the deny modes that you have specified.  An opWrErr is returned if you have asked for write permission and the file is already opened by you for write.  The already-opened path reference number is returned in ioRefNum.  An AccessDenied error is returned if you do not have the right to access the file.
  20353. \ GetMMUMode
  20354. 25
  20355. Function GetMMUMode (VAR mode: INTEGER);
  20356.  
  20357.     GetMMUMode returns the address translation mode currently in use.
  20358.  
  20359. Assembly-language note:  Assembly-language programmers can determine the current address mode by testing the contents of the global variable MMU32Bit; it’s TRUE if 32-bit mode is in effect.
  20360. \ SwapMMUMode
  20361. 25
  20362. Procedure SwapMMUMode (VAR mode: Byte);
  20363.  
  20364.         Trap macro _SwapMMUMode
  20365.  
  20366. On entry    D0:  mode (byte)
  20367.  
  20368. On exit     D0:  mode (byte)
  20369.  
  20370.     SwapMMUMode sets the address translation mode to that specified by the mode parameter.  The mode in use prior to the call is returned in mode, and can be restored with another call to SwapMMUMode.
  20371. \ StripAddress
  20372. 25
  20373. Function StripAddress (theAddress: LONGINT) : LONGINT;
  20374.  
  20375. Trap macro  _StripAddress
  20376.  
  20377. On entry    D0:  theAddress (long word)
  20378.  
  20379. On exit     D0:  function result (long word)
  20380.  
  20381.     If the system is running in 24-bit addressing mode, StripAddress is identical in function to the global variable Lo3Bytes:  it returns the value of the low-order three bytes of the address passed in theAddress.  If the system is in 32-bit mode, however, StripAddress simply passes back the address unchanged.
  20382. \ RGetResource
  20383. 1
  20384. Function RGetResource (theType: ResType; theID: INTEGER) : Handle;
  20385.  
  20386.     RGetResource is identical in function to GetResource except that it looks through the chain of open resource files for the specified resource, and if it doesn’t find it there, it looks in the ROM resources.
  20387.  
  20388. Note:  With System file version 4.1 or later, RGetResource will also work on the Macintosh Plus.
  20389. \ SCSIMsgIn
  20390. 34
  20391. Function SCSIMsgIn (VAR message: INTEGER) : OSErr;
  20392.  
  20393.     SCSIMsgIn gets a message from the device.  The message is contained in the low-order byte of the message parameter; message values are listed in the ANSI documentation for SCSI.
  20394.  
  20395.     SCSIMsgIn leaves the Attention line undisturbed if it’s already asserted upon entry.
  20396. \ SCSIMsgOut
  20397. 34
  20398. Function SCSIMsgOut (message: INTEGER) : OSErr;
  20399.  
  20400.     SCSIMsgOut sends a message byte to the target device; message values are listed in the ANSI documentation for SCSI.
  20401. \ ShutDwnPower
  20402. 45
  20403. Procedure ShutDwnPower;
  20404.  
  20405.     ShutDwnPower performs system housekeeping, executes any shutdown procedures you may have installed with ShutDwnInstall, and turns the machine off.  (If the machine must be turned off manually, the shutdown alert is presented.)
  20406. \ ShutDwnStart
  20407. 45
  20408. Procedure ShutDwnStart;
  20409.  
  20410.     ShutDwnPower performs system housekeeping, executes any shutdown procedures you may have installed with ShutDwnInstall, and reboots the machine.
  20411.  
  20412. Assembly-language note:  ShutDwnStart results in the execution of the Reset instruction, followed by a jump to the ROM boot code (the address is the value of the global variable ROMBase + 10).
  20413. \ ShutDwnInstall
  20414. 45
  20415. Procedure ShutDwnInstall (shutDwnProc: ProcPtr; flags: INTEGER);
  20416.  
  20417.     ShutDwnInstall installs the shutdown procedure pointed to by shutDwnProc.  The flags parameter indicates where in the shutdown process to execute your shutdown procedure.  The following masks are provided for setting the bits of the flags parameter:
  20418.  
  20419. CONST sdOnPowerOff  = 1;    {call procedure before power off}
  20420.       sdOnRestart   = 2;    {call procedure before restart}
  20421.       sdOnUnmount   = 4;    {call procedure before unmounting}
  20422.       sdOnDrivers   = 8;    {call procedure before closing drivers}
  20423.       sdRestartOrPower  = sdOnPowerOff + sdOnRestart {call procedure}
  20424.                             { before either power off or restart}
  20425. \ ShutDwnRemove
  20426. 45
  20427. Procedure ShutDwnRemove (shutDwnProc: ProcPtr);
  20428.  
  20429.     ShutDwnRemove removes the shutdown procedure pointed to by shutDwnProc.
  20430.  
  20431. Note:  If the procedure was marked for execution at a number of points in the shutdown process (say, for instance, at unmounting, restart, and power off), it will be removed at all points.
  20432. \ SRsrcInfo
  20433. 46
  20434. Function SRsrcInfo(spBlkPtr: SpBlockPtr) : OSErr;
  20435.  
  20436.         Trap macro: _SRsrcInfo
  20437.  
  20438. Required Parameters:
  20439.  
  20440.     <—— spsPointer
  20441.     <—— spIOReserved
  20442.     <—— spRefNum
  20443.     <—— spCategory
  20444.     <—— spCType
  20445.     <—— spDrvrSW
  20446.     <—— spDrvrHW
  20447.     ——> spSlot
  20448.     ——> spId
  20449.     ——> spExtDev
  20450.     <—— spHWDev
  20451.  
  20452.     The trap macro SRsrcInfo returns an sResource list pointer (spsPointer), plus the sResource type (category, cType, software, and hardware), driver reference number (spRefNum), and Slot Resource Table ioReserved field (spIOReserved) for the  sResource specified by the slot number spSlot, sResource list identification number spId, and external device identifier spExtDev.  This call is most often used to return the driver reference number.
  20453. \ SNextsRsrc
  20454. 46
  20455. Function SNextsRsrc(spBlkPtr: SpBlockPtr) : OSErr;
  20456.  
  20457.         Trap macro: _SNextsRsrc
  20458.  
  20459. Required Parameters:
  20460.     <—> spSlot
  20461.     <—> spId
  20462.     <—> spExtDev
  20463.     <—— spsPointer
  20464.     <—— spRefNum
  20465.     <—— spIOReserved
  20466.     <—— spCategory
  20467.     <—— spCType
  20468.     <—— spDrvrSW
  20469.     <—— spDrvrHW
  20470.     <—— spHWDev
  20471.  
  20472. Starting from a given slot number spSlot, sResource list identification number spId, and external device identifier spExtDev, the trap macro SNextsRsrc returns the slot number, sResource list identification number, sResource type (category, cType, software, and hardware), driver reference number (spRefNum), and Slot Resource Table ioReserved field (spIOReserved) for the next sResource.  If there are no more sResources, SNextsRsrc returns a nonfatal error status. This routine can be used to determine the set of all sResources in a given slot card or NuBus configuration.
  20473. \ SNextTypesRsrc
  20474. 46
  20475. Function SNextTypesRsrc(spBlkPtr: SpBlockPtr) : OSErr;
  20476. Trap macro: _SNextTypesRsrc
  20477. Required Parameters:
  20478.     <—> spSlot
  20479.     <—> spId
  20480.     <—> spExtDev
  20481.     ——> spTBMask
  20482.     <—— spsPointer
  20483.     <—— spRefNum
  20484.     <—— spIOReserved
  20485.     <—> spCategory
  20486.     <—> spCType
  20487.     <—> spDrvrSW
  20488.     <—> spDrvrHW
  20489.     <—> spHWDev
  20490.  
  20491.     Given an sResource type (category, cType, software, and hardware) and spTBMask, and starting from a given slot number spSlot and sResource list identification number spId, the trap macro SNextTypesRsrc returns the slot number spSlot, sResource list identification number spId, sResource type, driver reference number (spRefNum), and Slot Resource Table ioReserved field (spIOReserved) for the next sResource of that type, as masked. If there are no more sResources of that type, SNextTypesRsrc returns a nonfatal error report.
  20492.     The spTBMask field lets you mask off specific fields of the sResource type that you don’t care about, by setting any of bits 0–3. Bit 3 masks off the spCategory field; bit 2 the spCType field; bit 1 the spDrvrSW field; and bit 0 the spDrvrHW field.
  20493.     This procedure behaves the same as sNextsRsrc except that it returns information only about sResources of the specified type.
  20494. \ SReadDrvrName
  20495. 46
  20496. Function SReadDrvrName(spBlkPtr: SpBlockPtr) : OSErr;
  20497.  
  20498.         Trap macro: _SReadDrvrName
  20499.  
  20500. Required Parameters:
  20501.     ——> spSlot
  20502.     ——> spId
  20503.     ——> spResult
  20504. Other Parameters Affected:
  20505.         spSize
  20506.         spsPointer
  20507.  
  20508.     The trap macro SReadDrvrName reads the name of the sResource corresponding to the slot number spSlot and sResource list identification number spId, prefixes a period to the value of the cString and converts its type to Str255. It then reads the result into a Pascal string variable declared by the calling program and pointed to by spResult. The final driver name is compatible with the Open routine.
  20509. \ SReadByte
  20510. 46
  20511. Function SReadByte(spBlkPtr: SpBlockPtr) : OSErr;
  20512.  
  20513.         Trap macro: _SReadByte
  20514. Required Parameters:
  20515.     ——> spsPointer
  20516.     ——> spId
  20517.     <—— spResult
  20518. Other Parameters Affected
  20519.         spOffsetData
  20520.         spByteLanes
  20521.  
  20522.     The trap macro SReadByte returns in spResult an 8-bit value identified by spId from the sResource list pointed to by spsPointer. This routine’s low-order byte can return nonfatal error reports.
  20523. \ SReadWord
  20524. 46
  20525. Function SReadWord(spBlkPtr: SpBlockPtr) : OSErr;
  20526.  
  20527.         Trap macro: _SReadWord
  20528.  
  20529. Required Parameters:
  20530.     ——> spsPointer
  20531.     ——> spId
  20532.     <—— spResult
  20533. Other Parameters Affected
  20534.         spOffsetData
  20535.         spByteLanes
  20536.  
  20537.     The trap macro SReadWord returns in the low-order word of spResult a 16-bit value identified by spId from the sResource list pointed to by spsPointer. This routine can return nonfatal error reports.
  20538. \ sReadLong
  20539. 46
  20540. Function sReadLong(spBlkPtr: SpBlockPtr) : OSErr;
  20541.  
  20542.         Trap macro: _SReadLong
  20543. Required Parameters:
  20544.     ——> spsPointer
  20545.     ——> spId
  20546.     <—— spResult
  20547. Other Parameters Affected
  20548.         spOffsetData
  20549.         spByteLanes
  20550.         spSize
  20551.  
  20552.     The trap macro SReadLong returns in spResult a 32-bit value identified by spId from the sResource list pointed to by spsPointer. This routine can return nonfatal error reports.
  20553. \ SGetCString
  20554. 46
  20555. Function SGetCString(spBlkPtr: SpBlockPtr) : OSErr;
  20556.  
  20557.         Trap macro: _SGetCString
  20558. Required Parameters
  20559.     ——> spsPointer
  20560.     ——> spId
  20561.     <—— spResult
  20562. Other Parameters Affected
  20563.         spOffsetData
  20564.         spByteLanes
  20565.         spSize
  20566.         spFlags
  20567.  
  20568.     The trap macro SGetCString copies a cString identified by spId from the sResource list pointed to by spsPointer to a buffer pointed to by spResult. Memory for this buffer is automatically allocated by SGetCString.
  20569. \ SGetBlock
  20570. 46
  20571. Function SGetBlock(spBlkPtr: SpBlockPtr) : OSErr;
  20572.  
  20573.         Trap macro: _SGetBlock
  20574.  
  20575. Required Parameters:
  20576.     ——> spsPointer
  20577.     ——> spId
  20578.     <—— spResult
  20579. Other Parameters Affected
  20580.         spOffsetData
  20581.         spByteLanes
  20582.         spSize
  20583.         spFlags
  20584.  
  20585.     The trap macro SGetBlock copies the sBlock from the sResource list pointed to by spsPointer and identified by spId into a new block and returns a pointer to it in spResult.  The pointer in spResult should be disposed of by using the Memory Manager routine DisposPtr.
  20586. \ SFindStruct
  20587. 46
  20588. Function SFindStruct(spBlkPtr: SpBlockPtr) : OSErr;
  20589.  
  20590.         Trap macro: _ sFindStruct
  20591. Required Parameters:
  20592.     ——> spId
  20593.     <—> spsPointer
  20594. Other Parameters Affected
  20595.         spByteLanes
  20596.  
  20597.     The trap macro SFindStruct returns a pointer to the data structure defined by spId in the sResource list pointed to by spsPointer.
  20598. \ SReadStruct
  20599. 46
  20600. Function SReadStruct(spBlkPtr: SpBlockPtr) : OSErr;
  20601.  
  20602.         Trap macro: _SReadStruct
  20603. Required Parameters:
  20604.     ——> spsPointer
  20605.     ——> spSize
  20606.     ——> spResult
  20607. Other Parameter Affected
  20608.         spByteLanes
  20609.  
  20610.     The trap macro sReadStruct copies a structure of size spSize from the sResource list pointed to by spsPointer  into a new block allocated by the calling program and pointed to by spResult.
  20611. \ SReadInfo
  20612. 46
  20613. Function SReadInfo(spBlkPtr: SpBlockPtr) : OSErr;
  20614.  
  20615.     Trap macro: _SReadInfo
  20616.  
  20617. Required Parameters
  20618.     ——> spSlot
  20619.     ——> spResult
  20620. Other Parameter Affected
  20621.         spSize
  20622.  
  20623.  
  20624.     The trap macro SReadInfo reads the sInfo record identified by spSlot into a new record allocated by the calling program and pointed to by spResult. Here is the structure of the sInfo record:
  20625. TYPE
  20626.     SInfoRecPtr = ^SInfoRecord;
  20627.     SInfoRecord = PACKED RECORD
  20628.         siDirPtr: Ptr;          {pointer to directory}
  20629.         siInitStatusA: INTEGER; {initialization error}
  20630.         siInitStatusV: INTEGER; {status returned by vendor init code}
  20631.         siState: SignedByte;    {initialization state}
  20632.         siCPUByteLanes: SignedByte; {0=[d0..d7], 1=[d8..d15],  ...}
  20633.         siTopOfROM: SignedByte; {top of ROM = $FsFFFFFx, }
  20634.                                 { where x is TopOfROM}
  20635.         siStatusFlags: SignedByte; {bit 0--card is changed}
  20636.         siTOConstant: INTEGER;  {timeout constant for bus error}
  20637.         siReserved: SignedByte; {reserved}
  20638.       END;
  20639.  
  20640. Assembly-language note:  The sInfo record has the following structure in assembly language:
  20641. siDirPtr        Pointer to sResource directory (long)
  20642. siInitStatusA   Fundamental error (word)
  20643. siInitStatusV   Status returned by vendor init code (word)
  20644. siState         Initialization state—primary, secondary (byte)
  20645. siCPUByteLanes  Each bit set signifies a byte lane used (byte)
  20646. siTopOfROM      x such that Top of ROM = $FsFFFFFx (byte)
  20647. siStatusFlags   Bit 0 indicates if card has been changed (byte)
  20648. siTOConst       Timeout constant for bus error (word)
  20649. siReserved      Reserved—must be 0 (byte)
  20650. sInfoRecSize    Size of sInfo record
  20651.  
  20652.     The siDirPtr field of the sInfo record contains a pointer to the sResource directory in the configuration ROM.  The siInitStatusA field indicates the result of efforts to initialize the card.  A zero value indicates that the card is installed and operational.  A non-zero value is the Slot Manager error code indicating why the card could not be used.
  20653.     The siInitStatusV field contains the value returned by the card's primary initialization code (in the seStatus field of the seBlock).  Negative values cause the card to fail initialization.  Zero or positive values indicate that the card is operational.
  20654.     The siState field is used internally to indicate what initialization steps have occurred so far.
  20655.     The siCPUByteLanes field indicate which byte lanes are used by the card.
  20656.     The siTopOfROM field gives the last nibble of the address of the actual ByteLanes value in the fHeader record.
  20657.     The siStatusFlags field gives status information about the slot.  Currently only the fCardIsChanged bit has meaning.  A value of 1 indicates that the board ID of the installed card did not match the ID saved in parameter RAM—in other words, the card has been changed.
  20658.     The siTOConstant field contains the number of retries that will be performed when a bus error occurs while accessing the declaration ROM.  It defaults to 100, but may be set to another value with the TimeOut field in the board sResource of the card.
  20659.     The siReserved field is reserved and should have a value of 0.
  20660. \ SReadPRAMRec
  20661. 46
  20662. Function SReadPRAMRec(spBlkPtr: SpBlockPtr) : OSErr;
  20663.  
  20664.         Trap macro: _SReadPRAMRec
  20665. Required Parameters:
  20666.     ——> spSlot
  20667.     ——> spResult
  20668. Other Parameter Affected
  20669.         spSize
  20670.  
  20671.     The trap macro SReadPRAMRec copies the sPRAM record data for the slot identified by spSlot to a new record allocated by the calling program and pointed to by spResult.
  20672.     One sPRAM record for each slot resides in the Macintosh II parameter RAM. The sPRAM record is initialized during startup by InitsPRAMRecs, described below under “Advanced Routines”.  Here is its structure:
  20673.  
  20674. TYPE
  20675.     SPRAMRecPtr = ^SPRAMRecord;
  20676.     SPRAMRecord = PACKED RECORD
  20677.             boardID: INTEGER;   {Apple-defined card identification}
  20678.             vendorUse1: SignedByte; {reserved for vendor use}
  20679.             vendorUse2: SignedByte; {reserved for vendor use}
  20680.             vendorUse3: SignedByte; {reserved for vendor use}
  20681.             vendorUse4: SignedByte; {reserved for vendor use}
  20682.             vendorUse5: SignedByte; {reserved for vendor use}
  20683.             vendorUse6:  SignedByte; {reserved for vendor use}
  20684.           END;
  20685.  
  20686. Assembly-language note:  The sPRAM record has the following structure in assembly language:
  20687.  
  20688. boardID     Apple-defined card indentification (word)
  20689. vendorUse1  Reserved for vendor use (byte)
  20690. vendorUse2  Reserved for vendor use (byte)
  20691. vendorUse3  Reserved for vendor use (byte)
  20692. vendorUse4  Reserved for vendor use (byte)
  20693. vendorUse5  Reserved for vendor use (byte)
  20694. vendorUse6  Reserved for vendor use (byte)
  20695.  
  20696.     If a card is removed from its slot, the corresponding sPRAM record is cleared at the next system startup. If a different card is plugged back into the slot, the corresponding sPRAM record is reinitialized. A flag is set each time an sPRAM record is initialized, to alert the Start Manager.
  20697. \ SPutPRAMRec
  20698. 46
  20699. Function SPutPRAMRec(spBlkPtr: SpBlockPtr) : OSErr;
  20700.  
  20701.         Trap macro: _SPutPRAMRec
  20702.  
  20703. Required Parameters:
  20704.     ——> spSlot
  20705.     ——> spsPointer
  20706.  
  20707.     The trap macro SPutPRAMRec copies the logical data from the block referenced by spsPointer into the sPRAM record for the slot identified by spSlot.  This updates the Macintosh PRAM for that slot.  The sPRAM record is defined above under SReadPRAMRec.  In this record, the field boardId is an Apple-defined field and is protected during execution of SPutPRAMRec.
  20708. \ SReadFHeader
  20709. 46
  20710. Function SReadFHeader(spBlkPtr: SpBlockPtr) : OSErr;
  20711.  
  20712.         Trap macro: _SReadFHeader
  20713.  
  20714. Required Parameters:
  20715.     ——> spSlot
  20716.     ——> spResult
  20717. Other Parameters Affected
  20718.         spsPointer
  20719.         spByteLanes
  20720.         spSize
  20721.         spOffsetData
  20722.  
  20723.     The trap macro SReadFHeader copies the format block data for the slot designated by spSlot to an FHeader record allocated by the calling program and pointed to by spResult. Here is the structure of FHeader:
  20724. TYPE
  20725.     FHeaderRecPtr   = ^FHeaderRec;
  20726.     FHeaderRec  = PACKED RECORD
  20727.             fhDIROffset: LONGINT;   {offset to directory}
  20728.             fhLength: LONGINT;      {length of ROM}
  20729.             fhCRC: LONGINT;         {CRC}
  20730.             fhROMRev: SignedByte;   {revision of ROM}
  20731.             fhFormat: SignedByte;   {format - 2}
  20732.             fhTstPat: LONGINT;      {test pattern}
  20733.             fhReserved: INTEGER;    {reserved}
  20734.             fhByteLanes: SignedByte;{ByteLanes}
  20735.           END;
  20736.  
  20737. Assembly-language note:  The FHeader record has the following structure in assembly language:
  20738.  
  20739. fhDIROffset Offset to sResource directory (long)
  20740. fhLength    Length of card’s declaration ROM (long)
  20741. fhCRC       Declaration ROM checksum (long)
  20742. fhROMRev    ROM revision number (byte)
  20743. fhFormat    ROM format number (byte)
  20744. fhTstPat    Test Pattern (long)
  20745. fhReserved  Reserved (byte)
  20746. fhByteLanes Byte lanes used (byte)
  20747. fhSize      Size of the FHeader record
  20748.  
  20749.     The fHeader record exists at the highest address of a card’s declaration ROM, and should therefore be visible at the highest address in the card’s slot space.  The Slot Manager uses the fHeader record to verify that a card is installed in the slot, to determine its physical connection to NuBus (which byte lanes are used), and to locate the sResource directory.
  20750.     The fhDIROffset field of the fHeader record is a self-relative signed 24-bit offset to the sResource directory.  The high order byte must be 0, or a card initialization error occurs.
  20751.     The fhLength field gives the size of the configuration ROM.
  20752.     The fhCRC field gives the cyclic redundancy check (CRC) value of the declaration ROM.  The CRC value itself is taken as zero in the CRC calculation.
  20753.     The fhRomRev field gives the revision level of this declaration ROM.  Values greater than 9 cause a card initialization error.
  20754.     The fhFormat field identifies the format of the configuration ROM.  Only the value 1 (appleFormat ) is currently recognized as valid.
  20755.     The fhTstPat field is used to verify that the fhByteLanes field is correct.
  20756.     The fhReserved field must be zero.
  20757.     The fhByteLanes field indicates what NuBus byte lanes are used by the card.  Byte lanes are described in the “Access to Address Space” chapter of Designing Cards and Drivers for Macintosh II and Macintosh SE.
  20758. \ SCkCardStatus
  20759. 46
  20760. Function SCkCardStatus(spBlkPtr: SpBlockPtr) : OSErr;
  20761.  
  20762.         Trap macro: _SCkCardStatus
  20763.  
  20764. Required Parameter:
  20765.     ——> spSlot
  20766. Other Parameter Affected
  20767.     spResult
  20768. \ GetDefaultStartup
  20769. 48
  20770. Procedure GetDefaultStartup (paramBlock: DefStartPtr);
  20771.  
  20772.      <——    0   sdExtDevID  byte   or   <—— 0   sdReserved1 byte
  20773.     <—— 1   sdPartition byte        <—— 1   sdReserved2 byte
  20774.     <—— 2   sdSlotNum   byte        <—— 2   sdRefNum    word
  20775.     <—— 3   sdSRsrcID   byte
  20776.  
  20777.     GetDefaultStartup returns information about the default startup device from parameter RAM.  To determine which variant to use, you need to look at the sdRefNum field.  If this field contains a negative number, it’s the driver reference number for an SCSI device, which is all you need to know.  (SDReserved1 and sdReserved2 are reserved for future use.)
  20778.  
  20779.     If sdRefNum contains a positive number, you’ll need to access the information in the slotDev variant.  SDExtDevID is specified by a slot’s driver; it identifies one of perhaps several devices that are connected through a single slot.  SDSlotNum is the slot number  ($9 thru E) and sdSRsrcID is the sResource ID; see the Slot Manager chapter for details.
  20780. \ SetDefaultStartup
  20781. 48
  20782. Procedure SetDefaultStartup (paramBlock: DefStartPtr);
  20783.  
  20784.     ——> 0   sdExtDevID  byte or ——> 0   sdReserved1 byte
  20785.     ——> 1   sdPartition byte    ——> 1   sdReserved2 byte
  20786.     ——> 2   sdSlotNum   byte    ——> 2   sdRefNum    word
  20787.     ——> 3   sdSRsrcID   byte
  20788.  
  20789.     SetDefaultStartup specifies a device as the default startup device.  For a slot device, sdExtDevID (specified by the slot’s driver) identifies one of perhaps several devices that are connected through a single slot.  SDSlotNum is the slot number  ($9 thru E) and sdSRsrcID is the sResource ID; see the Slot Manager chapter for details.
  20790.  
  20791.     In the case of an SCSI device, sdRefNum contains the reference number; to specify no device as default (meaning that the first available device will be chosen at startup), pass 0 in sdRefNum.  SDReserved1 and sdReserved2 are reserved for future use and should be 0.
  20792. \ GetVideoDefault
  20793. 48
  20794. Procedure GetVideoDefault (paramBlock: DefVideoPtr);
  20795.  
  20796. Trap macro  _GetVideoDefault
  20797.  
  20798. Parameter block
  20799.     <—— 0   sdSlot      byte
  20800.     <—— 1   sdSResource byte
  20801.  
  20802.     GetVideoDefault returns the slot number and sResourceID of the default video device.  If sdSlot returns 0, there is no default video device and the first available video device will be chosen.
  20803. \ SetVideoDefault
  20804. 48
  20805. Procedure SetVideoDefault (paramBlock: DefVideoPtr);
  20806.  
  20807. Trap macro  _SetVideoDefault
  20808.  
  20809. Parameter block
  20810.     ——> 0   sdSlot  byte
  20811.     ——> 1   sdSResource byte
  20812.  
  20813.     SetVideoDefault makes the device with the given slot number and sResourceID the default video device.
  20814. \ GetOSDefault
  20815. 48
  20816. Procedure GetOSDefault (paramBlock: DefOSPtr);
  20817.  
  20818. Trap macro  _GetOSDefault
  20819.  
  20820. Parameter block
  20821.     <—— 0   sdReserved  byte
  20822.     <—— 1   sdOSType    byte
  20823.  
  20824.     GetOSDefault returns a value in sdOSType identifying the operating system to be used at startup.  The sdReserved parameter currently returns 0; it’s reserved for future use.  This call is generally used only with partitioned devices containing multiple operating systems; for more details, see the SCSI Manager chapter in this volume.
  20825. \ SetOSDefault
  20826. 48
  20827. Procedure SetOSDefault (paramBlock: DefOSPtr);
  20828.  
  20829. Trap macro  _SetOSDefault
  20830.  
  20831. Parameter block
  20832.     ——> 0   sdReserved  byte
  20833.     ——> 1   sdOSType    byte
  20834.  
  20835. SetOSDefault specifies in sdOSType the operating system to be used at startup.  The sdReserved parameter is reserved for future use and should be 0.  This call is generally used only with partitioned devices containing multiple operating systems; for details, see the SCSI Manager chapter in this volume.
  20836. \ GetTimeout
  20837. 48
  20838. Procedure GetTimeout (VAR count: INTEGER);
  20839. Trap macro  _GetTimeout
  20840.  
  20841. On exit
  20842.         D0:  count (word)
  20843.  
  20844. Note:  The _GetTimeout macro is actually not a trap, but expands to invoke the trap macro _InternalWait with a routine selector of 0 pushed on the stack.
  20845.     GetTimeout returns in count the number of seconds the system will wait for the internal hard disk to respond.  A value of 0 indicates the default timeout of 15 seconds.
  20846. \ SetTimeout
  20847. 48
  20848. Procedure SetTimeout (count: INTEGER);
  20849.  
  20850.         Trap macro  _SetTimeout
  20851.  
  20852. On entry
  20853.         D0:  count (word)
  20854.  
  20855. Note:  The _SetTimeout macro is actually not a trap, but expands to invoke the trap macro _InternalWait with a routine selector of 1 pushed on the stack.
  20856.     SetTimeout lets you specify in count the number of seconds the system should wait for the internal hard disk to respond.  The maximum value is 31 seconds; a value of 0 indicates the default timeout of 15 seconds.
  20857. \ DTInstall
  20858. 49
  20859. Function DTInstall (dtTaskPtr: QElemPtr) : OSErr;
  20860.  
  20861.         Trap macro _DTInstall
  20862.  
  20863. On entry
  20864.         A0:  dtTaskPtr (pointer)
  20865.  
  20866. On exit
  20867.         D0:  result code (word)
  20868.  
  20869. Note:  To reduce overhead at interrupt time, instead of executing the _DTInstall trap you can load the jump vector jDTInstall into an address register other than A0 and execute a JSR instruction using that register.
  20870.     DTInstall adds the specified task to the deferred task queue.  Your application must fill in all fields of the task except qLink.  DTInstall returns one of the result codes listed below.
  20871.  
  20872. Result codes
  20873.     noErr   No error
  20874.     vTypErr Invalid queue element
  20875. \ KeyTrans
  20876. 4
  20877. Function KeyTrans (transData: Ptr; keycode: Integer; VAR state: LONGINT) : LONGINT;
  20878.  
  20879.     TransData points to a 'KCHR' resource, which maps virtual key codes to ASCII values.  The keycode parameter is a 16-bit value with the structure shown in Figure 6.
  20880.  
  20881.     The state parameter is a value maintained by the Toolbox.  Your application should save it between calls to KeyTrans.  If your application changes transData to point to a different 'KCHR' resource, it should reset the state value to 0.
  20882.     KeyTrans returns a 32-bit value with the structure shown in Figure 7.  In this structure, ASCII 1 is the ASCII value of the first character generated by the key code parameter; reserved1 is an extension for future “16-bit ASCII” coding.  ASCII 2 and reserved2 have the same meanings for a possible second character generated by key code—for example, if key code designates an alphabetic character with a separate accent character.
  20883.  
  20884. Assembly-language note:  The macro you invoke to call KeyTrans from assembly language is named _KeyTrans. Its parameters are passed on the stack.
  20885. \ AttachVBL
  20886. 24
  20887. Function AttachVBL (theSlot: INTEGER) : OSErr;
  20888.  
  20889.         Trap macro _AttachVBL
  20890.  
  20891. On entry
  20892.         D0:  theSlot (word)
  20893.  
  20894. On exit
  20895.         D0:  result code (word)
  20896.  
  20897.     AttachVBL makes theSlot the primary video slot, allowing correct cursor updating.
  20898.  
  20899. Result codes
  20900.     noErr       No error
  20901.     slotNumErr  Invalid slot number
  20902. \ SlotVInstall
  20903. 24
  20904. Function SlotVInstall (vblTaskPtr: QElemPtr; theSlot:INTEGER) : OSErr;
  20905.  
  20906.         Trap macro  _SlotVInstall
  20907.  
  20908. On entry
  20909.     A0:  vblTaskPtr (pointer)
  20910.     D0:  theSlot (word)
  20911.  
  20912. On exit
  20913.     D0:  result code (word)
  20914.  
  20915.     SlotVInstall is identical in function to the VInstall function except that it installs the task in the queue for the device specified by theSlot.
  20916.  
  20917. Result codes
  20918.     noErr       No error
  20919.     vTypErr Invalid queue element
  20920.     slotNumErr  Invalid slot number
  20921. \ SlotVRemove
  20922. 24
  20923. Function SlotVRemove (vblTaskPtr: QElemPtr; theSlot: INTEGER) : OSErr;
  20924.  
  20925.         Trap macro  _SlotVRemove
  20926.  
  20927. On entry
  20928.     A0:  vblTaskPtr (pointer)
  20929.     D0:  theSlot (word)
  20930.  
  20931. On exit
  20932.     D0:  result code (word)
  20933.  
  20934.     SlotVRemove is identical in function to the VRemove function except that it removes the task from the queue for the slot specified by theSlot.
  20935.  
  20936. Result codes
  20937.     noErr       No error
  20938.     vTypErr     Invalid queue element
  20939.     slotNumErr  Invalid slot number
  20940. \ DoVBLTask
  20941. 24
  20942. Function DoVBLTask (theSlot: INTEGER) : OSErr;
  20943.  
  20944.         Trap macro  _DoVBLTask
  20945.  
  20946. On entry
  20947.         D0:  theSlot (word)
  20948.  
  20949. On exit
  20950.         D0:  result code (word)
  20951.  
  20952. Note:  To reduce overhead at interrupt time, instead of executing the _DoVBLTask trap you can load the jump vector jDoVBLTask into an address register and execute a JSR instruction using that register.
  20953.  
  20954.     DoVBLTask causes any VBL tasks in the queue for the specified slot to be executed.  If the specified slot is the primary video slot, the position of the cursor will also be updated.
  20955.  
  20956. Result codes
  20957.     noErr       No error
  20958.     slotNumErr  Invalid slot number
  20959. \ ADBReInit
  20960. 31
  20961. Procedure ADBReInit;
  20962.  
  20963.     ADBReInit reinitializes the entire Apple Desktop Bus. It clears the ADB device table to zeros and places a SendReset command on the bus to reset all devices to their original addresses. ADBReInit has no parameters.
  20964.     ADBReInit is intended to be used only by installer programs that permit a new device to be connected to the ADB while the system is running.  Because it does not deallocate ADB resources on the system heap, ADBReInit should not be used for routine bus initialization.
  20965.     ADBReInit also calls a routine pointed to by the low memory global JADBProc at the beginning and end of its execution.  You can insert your own preprocessing/ postprocessing routine by changing the value of JADBProc; ADBReInit conditions it by setting D0 to 0 for preprocessing and to 1 for postprocessing.  Your procedure must restore the value of D0 and branch to the original value of JADBProc on exit.  The complete ADBReInit sequence is therefore the following:
  20966.  
  20967. \ ADBOp
  20968. 31
  20969. Function ADBOp (data: Ptr; compRout: ProcPtr; buffer: Ptr; commandNum: INTEGER) : OSErr;
  20970.  
  20971. On entry:
  20972.      A0:  pointer to parameter block
  20973.      D0:  commandNum (byte)
  20974.  
  20975. Parameter block
  20976.             • 0 buffer   pointer
  20977.             • 4 compRout pointer
  20978.             • 8 data     pointer
  20979.  
  20980. On exit:
  20981.      D0:  result code (byte)
  20982.  
  20983. The completion routine pointed to by compRout will be passed the following parameters on entry:
  20984.     D0:  commandNum (byte)
  20985.     A0:  pointer to data stored as a Pascal string (maximum
  20986.             8 bytes data preceded by one length byte)
  20987.     A1:  pointer to completion routine
  20988.     A2:  pointer to optional data area
  20989.  
  20990.     ADBOp transmits over the bus the command byte whose value is given by commandNum. The structure of the command byte is given earlier in Figure 1. ADBOp executes only when the ADB is otherwise idle; otherwise it is held in a command queue. It returns an error if the command queue is full. The length of the data buffer pointed to by buffer is contained in its first byte, like a Pascal string. The optional data area pointed to by data is for local storage by the completion routine pointed to by compRout.
  20991.  
  20992. Result codes
  20993.         noErr No error
  20994.         –1    Unsuccessful completion
  20995. \ CountADBs
  20996. 31
  20997. Function CountADBs: INTEGER;
  20998.  
  20999. On exit:
  21000.     D0:  number of devices (byte)
  21001.  
  21002.     CountADBs returns a value representing the number of devices connected to the ADB by counting the number of entries in the device table. It has no arguments and returns no error codes.
  21003. \ GetIndADB
  21004. 31
  21005. Function GetIndADB (VAR info: ADBDataBlock; devTableIndex: INTEGER) : ADBAddress;
  21006.  
  21007. On entry:
  21008.         A0:  pointer to parameter block
  21009.         D0:  entry index number; range = 1..CountADBs (byte)
  21010.  
  21011. Parameter block
  21012.     •   0   device type             byte
  21013.     •   1   original ADB address    byte
  21014.     •   2   service routine         address pointer
  21015.     •   6   data area address       pointer
  21016.  
  21017. On exit:
  21018.     D0:     positive value:  current ADB address (byte)
  21019.             negative value:  error code (byte)
  21020.  
  21021.     GetIndADB returns information from the ADB device table entry whose index number is given by devTableIndex. ADBDataBlock has this form:
  21022.  
  21023. TYPE ADBDataBlock = PACKED RECORD
  21024.                devType: SignedByte;     {device type}
  21025.                origADBAddr: SignedByte; {original ADB address}
  21026.                dbServiceRtPtr: Ptr;     {service routine address}
  21027.                dbDataAreaAddr: Ptr      {data area address}
  21028.           END;
  21029.  
  21030.     GetIndADB returns the current ADB address of the device. If it is unable to complete execution successfully, GetIndADB returns a negative value.
  21031. \ GetADBInfo
  21032. 31
  21033. Function GetADBInfo (VAR info: ADBDataBlock; ADBAddr: ADBAddress) : OsErr;
  21034.  
  21035. On entry:
  21036.     A0:  pointer to parameter block
  21037.     D0:  ADB address of the device (byte)
  21038.  
  21039. Parameter block
  21040.     •   0   device handler ID       byte
  21041.     •   1   original ADB address    byte
  21042.     •   2   service routine address pointer
  21043.     •   6   data area address       pointer
  21044.  
  21045. On exit:
  21046.     D0:  result code (byte)
  21047.  
  21048.     GetADBInfo returns information from the ADB device table entry of the device whose ADB address is given by ABDAddr. The structure of ADBDataBlock is given above under “GetIndADB”.
  21049. \ SetADBInfo
  21050. 31
  21051. Function SetADBInfo (VAR info: ADBSetInfoBlock; ADBAddr: ADBAddress) : OsErr;
  21052.  
  21053. On entry:
  21054.     A0:  pointer to parameter block
  21055.     D0:  ADB address of the device (byte)
  21056.  
  21057. Parameter block
  21058.     •   0   service routine address pointer
  21059.     •   4   data area address   pointer
  21060.  
  21061. On exit:
  21062.     D0:  result code (byte)
  21063.  
  21064.     SetADBInfo sets the service routine address and the data area address in the ADB device table entry for the device whose ADB address is given by ABDAddr. ADBSetInfoBlock has this form:
  21065.  
  21066. TYPE ADBSetInfoBlock = RECORD
  21067.             siServiceRtPtr: Ptr;    {service routine address}
  21068.             siDataAreaAddr: Ptr     {data area address}
  21069.           END;
  21070.  
  21071. Warning:  You should send a Flush command to the device after calling it with SetADBInfo, to prevent it sending old data to the new data area address.
  21072. \ OpenSlot
  21073. 19
  21074. Function OpenSlot(paramBlock: paramBlkPtr; aSync: BOOLEAN) : OsErr;
  21075.  
  21076.     If the slot sResource serves a single device (for example, a video device), clear all the bits of the ioFlags field and use the following parameter block:
  21077.  
  21078. Parameter block
  21079.  
  21080. ——> 12  ioCompletion    pointer
  21081. <-- 16  ioResult        word
  21082. ——> 18  ioNamePtr       pointer
  21083. <-- 22  ioRefNum        word
  21084. ——> 27  ioPermssn       byte
  21085. ——> 28  ioMix           pointer
  21086. ——> 32  ioFlags         word
  21087. ——> 34  ioSlot          byte
  21088. ——> 35  ioId            byte
  21089.  
  21090.     In the extension fields, ioMix is a pointer reserved for use by the driver open routine.  The ioSlot parameter contains the slot number of the device being opened, in the range 9..$E; if a built-in device is being opened, ioSlot must be 0.  The ioId parameter contains the sResource ID.  Slot numbers and sResources are discussed in the Slot Manager chapter of this volume.
  21091.  
  21092.     If the slot sResource serves more than one device (for example, a chain of disk drives), set the fMulti bit in the ioFlags field (clearing all other flags bits to 0) and use the following parameter block:
  21093.  
  21094. Parameter block
  21095.  
  21096. ——> 12  ioCompletion    pointer
  21097. <-- 16  ioResult        word
  21098. ——> 18  ioNamePtr       pointer
  21099. <-- 22  ioRefNum        word
  21100. ——> 27  ioPermssn       byte
  21101. ——> 28  ioMix           pointer
  21102. ——> 32  ioFlags         word
  21103. ——> 34  ioSEBlkPtr      pointer
  21104.  
  21105. \ SIntInstall
  21106. 19
  21107. Function SIntInstall(sIntQElemPtr: SQElemPtr; theSlot: INTEGER) : OsErr;
  21108.  
  21109.     Trap macro  _SIntInstall
  21110.  
  21111. On entry    D0:  slot number (word)
  21112.             A0:  address of slot queue element
  21113. On exit     D0:  error code
  21114.  
  21115.     SIntInstall adds a new element (pointed to by sIntQElemPtr) to the interrupt queue for the slot whose number is given in theSlot.  As explained in the Slot Manager chapter of this volume, slots are numbered from 9 to $E.
  21116.  
  21117. Assembly-language note:  From assembly language, this routine has the following calling sequence (assuming A0 points to a slot queue element):
  21118.  
  21119.     LEA     PollRoutine,A1      ;get routine address
  21120.     MOVE.L  A1,SQAddr(A0)       ;set address
  21121.     MOVE.W  Prio,SQPrio(A0)     ;set priority
  21122.     MOVE.L  A1Parm, SQParm(A0)  ;save A1 parameter
  21123.     MOVE.W  Slot,D0         ;set slot number
  21124.     _SIntInstall            ;do installation
  21125.  
  21126.     This code causes the routine at label PollRoutine to be called as a result of an interrupt from the specified slot (9..$E).   The Device Manager will poll the slot which has the highest priority first if two or more slots request an interrupt simultaneously.
  21127.  
  21128. \ SIntRemove
  21129. 19
  21130. Function SIntRemove(sIntQElemPtr: SQElemPtr; theSlot: INTEGER) : OsErr;
  21131.  
  21132.         Trap macro  _SIntRemove
  21133.  
  21134. On entry    D0:  slot number (word)
  21135.             A0:  address of slot queue element
  21136. On exit     D0:  error code
  21137.  
  21138.     SIntRemove removes an element (pointed to by sIntQElemPtr) from the interrupt queue for the slot whose number is given in theSlot.  As explained in the Slot Manager chapter of this volume, slots are numbered from 9 to $E.
  21139.  
  21140. Assembly-language note:  From assembly language, this routine has the following calling sequence (assuming A0 points to a slot queue element):
  21141.  
  21142.     LEA     MySQEl,A0   ;pointer to queue element
  21143.     _SIntRemove         ;remove it
  21144.  
  21145.     This routine lets you remove an interrupt handler from the system without causing a crash.
  21146.  
  21147.     Your driver polling routine will be called with the following assembly-language code:
  21148.  
  21149.     MOVE.L  A1Parm,A1   ;load A1 Parameter
  21150.     JSR     PollRoutine ;call polling routine
  21151.  
  21152.     Your polling routine should preserve the contents of all registers except A1 and D0.  It should return to the Device Manager with an RTS instruction. D0 should be set to zero to indicate that the polling routine did not service the interrupt, or nonzero to indicate the interrupt has been serviced.  The polling routine should not set the processor priority below 2, and should return with the processor priority equal to 2.  The Device Manager resets the VIA2 int flag and executes an RTE to the interrrupted task when a polling routine indicates that the interrupt is satisfied; otherwise, it calls the next lower-priority polling routine for that slot.  If none exists, a system error results.
  21153. \ SetChooserAlert
  21154. 19
  21155. Function SetChooserAlert (f:BOOLEAN) : BOOLEAN;
  21156.  
  21157.     If f is true, the Chooser will put up the page setup alert; if f is false it won’t.  SetChooserAlert returns the original alert state.  The application should restore the original alert state when it exits.
  21158.  
  21159. Assembly-language note:  If the psAlert bit of the low-memory global HiliteMode is 0 then no page setup alert will be generated.  Applications that set or clear this bit must be sure not to affect any other bits in the byte and to restore the bit as they leave.
  21160.  
  21161.     HiliteMode  equ $938
  21162.     psAlert     equ 6
  21163.  
  21164.     bclr        #psAlert,HiliteMode
  21165.     bset        #psAlert,HiliteMode
  21166. \ SndPlay
  21167. 47
  21168. Function SndPlay (chan: SndChannelPtr; sndHdl: Handle; async: BOOLEAN): OSErr;
  21169.  
  21170.     SndPlay plays the 'snd ' resource specified by sndHdl.  If the resource specifies a synthesizer and any modifiers to be used,  the appropriate 'snth' resources are loaded and linked to the channel.  The commands in the 'snd ' resource are then passed to the channel.
  21171.  
  21172.     If chan is NIL and no modifiers are specified in the 'snd ' resource, SndPlay allocates a channel defaulting to the note synthesizer.  This channel is released after the commands in the resource have been processed (in other words, after the sounds have been played).
  21173.  
  21174.     If you specify a channel in chan, you can call SndPlay asynchronously by passing TRUE in async.  If chan is NIL, you must pass FALSE in async.
  21175.  
  21176. Result codes
  21177.     noErr       No error
  21178.     resProblem  Problem loading resource
  21179.     badFormat   Handle to 'snd ' resource was invalid
  21180.     badChannel  Invalid channel queue length
  21181. \ SndNewChannel
  21182. 47
  21183. Function SndNewChannel (VAR chan: SndChannelPtr; synth: INTEGER; init: LONGINT; userRoutine: ProcPtr) : OSErr;
  21184.  
  21185.     SndNewChannel opens a new channel.  If you pass NIL for the chan parameter, the Sound Manager opens a channel for you and returns a pointer to it.
  21186.  
  21187. Advanced programmers:  If you’re particularly concerned with memory management, you may want to allocate a SndChannel record yourself and pass a pointer to it in chan; for details on doing this, see “Sound Manager Data Structures” below.
  21188.  
  21189. Synth indicates the synthesizer to be used; the following standard values have been defined:
  21190.  
  21191. CONST
  21192.     noteSynth       = 1;    {note synthesizer}
  21193.     waveTableSynth  = 3;    {wave table synthesizer}
  21194.     sampledSynth    = 5;    {sampled sound synthesizer}
  21195.     MIDISynthIn     = 7;    {MIDI synthesizer in}
  21196.     MIDISynthOut    = 9;    {MIDI synthesizer out}
  21197.  
  21198.     If you pass 0 for synth, no synthesizer is linked to the channel; you’d do this only if you intended to process commands using modifiers alone.
  21199.  
  21200.     The init parameter is sent to the synthesizer as the second parameter of the initCmd command; its possible values are given in the description of initCmd below.  The init parameter lets you request a channel with certain characteristics; this is only a request.  To determine whether the requested characteristics were available, you can send the availableCmd command (described below) using the SndControl function.
  21201.  
  21202.     If you want to supply a “call-back” routine, pass a pointer to it in userRoutine; if you pass NIL, callBackCmd commands are ignored (see “User Routines” below for a discussion of the call back routine).
  21203.  
  21204. Result codes
  21205.     noErr       No error
  21206.     resProblem  Problem loading resource
  21207.     badChannel  Invalid channel queue length
  21208.  
  21209.  
  21210. \ SndAddModifier
  21211. 47
  21212. Function SndAddModifier (chan: SndChannelPtr; modifier: ProcPtr; id: INTEGER; init: LONGINT) : OSErr;
  21213.  
  21214.     SndAddModifier lets you add a modifier to an open channel.  Chan contains a pointer to the channel.  SndAddModifier always adds the modifier in front of the synthesizer, and in front of any modifiers previously installed.
  21215.  
  21216.     If you want to load a 'snth' resource and add it as a modifier, pass NIL in the modifier parameter and pass the resource ID in id.  The Sound Manager will load the resource, lock it, and link it to the channel.
  21217.  
  21218. Note:  The Sound Manager saves the state of the pointer (with HGetState) and restores it when SndDisposeChannel is called (using HSetState).
  21219.  
  21220.     If you want to add your own procedure as a modifier (instead of using an 'snth' resource), simply pass a pointer to it in the modifier parameter.  The format of a modifier procedure is given in “User Routines” below.
  21221.  
  21222. Warning:  Having too many modifiers per channel may degrade performance.
  21223.  
  21224. Result codes
  21225.     noErr       No error
  21226.     resProblem  Problem loading resource
  21227.     badChannel  Invalid channel queue length
  21228. \ SndDoCommand
  21229. 47
  21230. Function SndDoCommand (chan: SndChannelPtr; cmd: SndCommand; noWait: BOOLEAN) : OSErr;
  21231.  
  21232.     SndDoCommand inserts the given command at the end of the channel.  If you specify FALSE for the noWait parameter and the queue is full, SndDoCommand waits for room in the queue.  If you pass TRUE and the queue is full, SndDoCommand will not insert the command, and the result code queueFull will be returned.
  21233.  
  21234. Result codes
  21235.     noErr       No error
  21236.     queueFull   No room in the queue
  21237.     badChannel  Invalid channel queue length
  21238. \ SndDoImmediate
  21239. 47
  21240. Function SndDoImmediate (chan: SndChannelPtr; cmd: SndCommand) : OSErr;
  21241.  
  21242.     SndDoImmediate bypasses the queue and passes the given command directly to the modifiers and synthesizer.
  21243.  
  21244. Note:  SndDoImmediate passes the command on even if the channel is waiting in response to a waitCmd or syncCmd command (described below).
  21245.  
  21246. Result codes
  21247.     noErr       No error
  21248.     badChannel  Invalid channel queue length
  21249. \ SndControl
  21250. 47
  21251. Function SndControl (id: INTEGER; VAR cmd: SndCommand) : OSErr;
  21252.  
  21253.     SndControl sends the given command directly to the modifier or synthesizer whose resource ID is in id.  The result, if any, is returned in cmd.  (Currently, only the availableCmd command is sent with SndControl; it’s described below.)
  21254.  
  21255. Result codes    noErr   No error
  21256.     badChannel  Invalid channel queue length
  21257.  
  21258.  
  21259. \ SndDisposeChannel
  21260. 47
  21261. Function SndDisposeChannel (chan: SndChannelPtr; quitNow: BOOLEAN) : OSErr;
  21262.  
  21263.     SndDisposeChannel closes a channel, releasing all data structures associated with it, as well as any 'snth' resources held by it.  (Remember that if you allocated the SndChannel record yourself, the Sound Manager will simply restore the pointer to its original state with a call to HSetState.)
  21264.  
  21265.     If you specify FALSE for quitNow, SndDispose channel simply places a quietCmd in the queue; commands already in the queue are processed.  If you specify TRUE for quitNow, a flushCmd is passed, flushing all commands from the queue, and then a quietCmd is placed in the queue.
  21266.  
  21267. Result codes
  21268.     noErr       No error
  21269.     badChannel  Invalid channel queue length
  21270. \ StartSound
  21271. 21
  21272. Procedure StartSound (synthRec: Ptr; numBytes: LONGINT; completionRtn:
  21273.         ProcPtr);
  21274.  
  21275.     StartSound begins producing the sound(s) described by the
  21276. synthesizer buffer pointed to by synthRec. NumBytes indicates the
  21277. length of the synthesizer buffer (in bytes), and completionRtn points to
  21278. a completion routine to be executed when the sound finishes:
  21279.  
  21280.     - If completionRtn is POINTER(-1), the sound will be produced
  21281.       synchronously.
  21282.  
  21283.     - If completionRtn is NIL, the sound will be produced
  21284.       asynchronously, but no completion routine will be executed.
  21285.  
  21286.     - Otherwise, the sound will be produced asynchronously and the
  21287.       routine pointed to by completionRtn will be executed when the
  21288.       sound finishes.
  21289.  
  21290. (warning)
  21291.     You may want the completion routine to start the next
  21292.     sound when one sound finishes, but beware:  Completion
  21293.     routines are executed at the interrupt level, and
  21294.     shouldn't make any calls to the Memory Manager. Be sure
  21295.     to preallocate all the space you'll need. Or, instead of
  21296.     using a completion routine to start the next sound, the
  21297.     completion routine can post an application-defined event
  21298.     and your application's main event lop can start the next
  21299.     sound when it gets the event.
  21300.  
  21301.     Because the type of pointer for each type of synthesizer buffer is
  21302. different and the type of the synthRec parameter is Ptr, you'll need to
  21303. do something like the following example (which applies to the free-form
  21304. synthesizer):
  21305.  
  21306.     VAR myPtr: Ptr;
  21307.         myHandle: Handle;
  21308.         myFFPtr: FFSynthPtr;
  21309.         ...
  21310.     myHandle := NewHandle(buffSize);     {allocate space for the buffer}
  21311.     HLock(myHandle);             {lock the buffer}
  21312.     myPtr := myHandle^;          {dereference the handle}
  21313.     myFFPtr := FFSynthPtr(myPtr);        {coerce type to FFSynthPtr}
  21314.     myFFPtr^.mode := ffMode;         {identify the synthesizer}
  21315.     ...                  {fill the buffer with values}
  21316.                          {describing the sound}
  21317.     StartSound(myPtr,buffSize,POINTER(-1));    {produce the sound}
  21318.     HUnlock(myHandle)              {unlock the buffer}
  21319.  
  21320. where buffSize is the length of the synthesizer record.
  21321.  
  21322. The sounds are generated as follows:
  21323.  
  21324.     - Free-form synthesizer:  The magnitudes described by each byte in
  21325.       the waveform description are genereated sequentially until the
  21326.       number of bytes specified by the numBytes paramaeter have been
  21327.       written.
  21328.  
  21329.     - Square-wave synthesizer:  The sounds described by each sound
  21330.       triplet are generaed sequentially until either the end of the
  21331.       buffer has been reached (indicated by a count, amplitude, and
  21332.       duration of 0 in the square-wave buffer), or the number of bytes
  21333.       specified by the numBytes parameter have been written.
  21334.  
  21335.     - Four-tone synthesizer:  All four sounds are generated for the
  21336.       length of time specified by the duration integer in the four-tone
  21337.       record.
  21338. \ StopSound
  21339. 21
  21340. Procedure StopSound;
  21341.  
  21342.     StopSound immediately stops the current StartSound call (if any),
  21343. executes the current StartSound call's completion routine (if any), and
  21344. cancels any pending asynchrounous StartSound calls.
  21345. \ SoundDone
  21346. 21
  21347. Function SoundDone : BOOLEAN;
  21348.  
  21349.     SoundDone returns TRUE if the Sound Driver isn't currently producing
  21350. sound and there are no asynchronous StartSound calls pending; otherwise
  21351. it returns FALSE.
  21352. \ GetSoundVol
  21353. 21
  21354. Procedure GetSoundVol (VAR level: INTEGER);
  21355.  
  21356.     GetSoundVol returns the current speaker volume, from 0 (silence) to
  21357. 7 (loudest).
  21358.  
  21359.     __________________________________________________________________
  21360.  
  21361.     Assembly-language note:  To set the speaker volume level from
  21362.     assembly language, call this Pascal routine from your program.
  21363.     As a side effect, it will set the low-order three bits of the
  21364.     global variable SdVolume to the specified level.
  21365.     __________________________________________________________________
  21366.  
  21367. (note)
  21368.     Your program shouldn't change the speaker volume unless
  21369.     it's a Control Panel-like desk accessory, since it's
  21370.     really up to the user to choose the desired volume level
  21371.     via the Control Panel.
  21372. \ General Information
  21373. 50
  21374. Interface Information for HyperCard 2.0 XCMDS
  21375.  
  21376. HyperCard 2.0: The Extended XCMD Interface 4 October 1990
  21377. External Windows: How They Work
  21378. External windows are an extension of external commands (XCMDs and XFCNs). Two new callbacks, NewXWindow and GetNewXWindow, cause HyperCard to create a new window and save with it a reference to the XCMD that made the call. Then, whenever HyperCard receives an event from the Toolbox Event Manager which belongs to the window, it calls the XCMD that created the window with arguments that allow it to handle the event. Otherwise, HyperCard handles the event itself.
  21379. Whenever an XCMD is called by HyperCard, it receives a pointer to an XCMDBlock, just as it did in earlier versions of HyperCard.
  21380.   XCmdPtr   = ^XCmdBlock;
  21381.   XCmdBlock = RECORD
  21382.                 paramCount:     INTEGER;
  21383.                 params:         ARRAY[1..16] OF Handle;
  21384.                 returnValue:    Handle; 
  21385.                 passFlag:       BOOLEAN;
  21386.                 entryPoint:     ProcPtr; { to call back to HyperCard }
  21387.                 request:        INTEGER;
  21388.                 result:         INTEGER;
  21389.                 inArgs:         ARRAY[1..8] OF LongInt;
  21390.                 outArgs:        ARRAY[1..4] OF LongInt;
  21391.               END;
  21392.  
  21393. When HyperCard calls an XCMD to handle an event for an external window, some of the fields of the XCMDBlock have a new meaning. The paramCount field is set to -1, indicating that the XCMD has been called to handle an event. The first parameter, params[1],  is a pointer to an XWEventInfo block, defined as follows.
  21394.   XWEventInfoPtr = ^XWEventInfo;
  21395.   XWEventInfo    = RECORD
  21396.                      event:       EventRecord;
  21397.                      eventWindow: WindowPtr;
  21398.                      eventParams: ARRAY[1..9] OF LongInt;
  21399.                      eventResult: Handle;
  21400.                    END;
  21401.  
  21402. Therefore, an XCMD that manages an external window can be structured as follows:
  21403.   IF paramPtr^.paramCount >= 0 THEN CreateMyWindow
  21404.   ELSE
  21405.     BEGIN
  21406.       WITH XWEventInfoPtr(paramPtr^.params[1])^ DO
  21407.         BEGIN
  21408.           myEvent := event;
  21409.           myWindow := eventWindow;
  21410.         END;
  21411.       SetPort(myWindow);
  21412.       CASE myEvent.what OF
  21413.         mouseDown: DoMouse;
  21414.         etc...
  21415.       END;
  21416.     END;
  21417.  
  21418. When an external window is called to handle an event, it has full access to HyperTalk callback routines, just as it does when invoked from a HyperTalk script.
  21419.  
  21420. Events
  21421.  
  21422. HyperCard will automatically send most standard Macintosh events to XCMDs that manage external windows. These include:
  21423. nullEvent       {see SetXWIdleTime}
  21424. mouseDown
  21425. updateEvt
  21426. activateEvt
  21427. app4Evt         {floaters should hide themselves when suspended and
  21428.                 show themselves when resumed}
  21429. Keyboard events are sent if the XCMD is the current editing environment:
  21430. keyDown         {sent if BeginXWEdit has been called}
  21431. autoKey         {sent if BeginXWEdit has been called}
  21432.  
  21433. Keyboard events are delivered to the XCMD only if it has registered itself as the active editing environment, i.e. “has edit”, with the BeginXWEdit callback. All keystrokes, with the exception of command-key combinations recognized by the menu manager as equivalents of menu items, are sent to an XCMD when it has edit.
  21434. In addition, XCMDs will receive messages specific to HyperCard. These are delivered in the same EventRecord data structure used for standard Macintosh events, with the what field set to one of the following constants:
  21435.   xOpenEvt          = 1000;  { the first event after you are created }
  21436.   xCloseEvt         = 1001;  { your window is being forced close (Quit?) }
  21437.   xGiveUpEditEvt    = 1002;  { you are losing Edit... }
  21438.   xGiveUpSoundEvt   = 1003;  { someone else is requesting HyperCard's sound channel }
  21439.   xHidePalettesEvt  = 1004;  { someone called HideHCPalettes }
  21440.   xShowPalettesEvt  = 1005;  { someone called ShowHCPalettes }
  21441.   xEditUndo         = 1100;  { Edit——Undo }
  21442.   xEditCut          = 1102;  { Edit——Cut }
  21443.   xEditCopy         = 1103;  { Edit——Copy }
  21444.   xEditPaste        = 1104;  { Edit——Paste }
  21445.   xEditClear        = 1105;  { Edit——Clear }
  21446.   xSendEvt          = 1200;  { script has sent you a message (text) }
  21447.   xSetPropEvt       = 1201;  { set a window property }
  21448.   xGetPropEvt       = 1202;  { get a window property }
  21449.   xCursorWithin     = 1300;  { cursor is within the window }
  21450.   xMenuEvt          = 1400;  { user has selected an item in your menu }
  21451.   xMBarClickedEvt   = 1401;  { a menu is about to be shown--update if needed }
  21452.   xShowWatchInfoEvt = 1501;  { for variable and message watchers }
  21453.   xScriptErrorEvt   = 1502;  { place the insertion point }
  21454.   xDebugErrorEvt    = 1503;  { user clicked “Debug” at a complaint }
  21455.   xDebugStepEvt     = 1504;  { hilite the line }
  21456.   xDebugTraceEvt    = 1505;  { same as step but tracing }
  21457.   xDebugFinishedEvt = 1506;  { script ended }
  21458.  
  21459.  
  21460. Handling Events
  21461. Many of the events above require special attention. Many are specific to the debugger, or other debugging tools. Here is a summary of all the events and their appropriate behavior:
  21462. nullEvent
  21463. If an external window requires idle time and registers itself as such using the SetXWIdleTime callback, it is called periodically with a nullEvent.
  21464. mouseDown, updateEvt, app4Evt
  21465. These events are dispatched in the same manner as the Toolbox Event Manager. 
  21466. activateEvt
  21467. For external windows in the document layer (the same layer as the card window), activate/deactivate events are dispatched in the same manner as the Toolbox Event Manager. However, external windows in the floating layer never receive activate or deactivate events. Windows in the floating layer should always appear “active”. If your external window requires more modality, then place it in the document layer.
  21468. keyDown, autoKey
  21469. If an external window has become the active editing window by calling BeginXWEdit, it receives all keystrokes as standard Macintosh events.
  21470. xOpenEvt
  21471. After the XCMD which created the external windows completes execution, HyperTalk sends an xOpenEvt to the new external window. This is always the first event an external window receives. 
  21472. xCloseEvt
  21473. HyperTalk sends your external window an xCloseEvt when your window has called CloseXWindow, when another external window or XCMD has called CloseXWindow using your window’s WindowPtr, or when the user has used the new close window “windowName” command. The external window should not dispose of any of its data until receiving this event. If the external window sets passFlag to TRUE, the window is disposed. If not, the window is left open. Refer to the discussion of the CloseXWindow callback for more information.
  21474. xGiveUpEditEvt
  21475. When an external window calls BeginXWEdit, it will receive keystrokes and edit menu commands until the user clicks back in the card window, or activates some other editing window (eg: the Message Box). HyperTalk signals the current editor with an xGiveUpEditEvt just before it activates the other editor.
  21476. xGiveUpSoundEvt
  21477. In the event that one external window requests the sound channel (with BeginXSound) while another external window has the channel, the current owner is given an xGiveUpSoundEvt. If the external window doesn’t set passFlag to true, the other external window’s callback returns with the result code set to xresFail. If an XCMD owns the sound channel, it can’t be notified of the second request, so that request will fail. The only exception to this is the HyperCard patch to _SysBeep; if an XCMD or external window owns the sound channel and someone calls SysBeep, HyperCard flashes the menubar rather than calling the XCMD.
  21478. xHidePalettesEvt
  21479. If another external window uses the HideHCPalettes callback, all external windows in the floating layer receive an xHidePalettesEvt. An example of this is the built-in Script Editor; it calls HideHCPalettes when the user edits a script.
  21480. xShowPalettesEvt
  21481. If another external window uses the ShowHCPalettes callback, all external windows in the floating layer receive an xShowPalettesEvt.
  21482. xEditUndo,xEditCut,xEditCopy,xEditPaste,xEditClear
  21483. While an external window has edit, it receives these events to correspond to the items in HyperCard’s built-in Edit menu.
  21484. xSendEvt
  21485. When a user issues the send “message” to window “windowName” command, or when an XCMD or external window issues the SendWindowMessage callback, the external command receives an xSendEvt. When this event is received, eventParams[1] contains a pointer to a Pascal string (Str255) containing the name of the message. This is done for speed purposes and to expedite using the StringEqual callback to index through the commands your window supports.
  21486. xSetPropEvt,xGetPropEvt
  21487. HyperTalk contains new extensible syntax for getting and setting properties of external windows. The syntax is:
  21488.     get “property” of window “windowName”
  21489.     set “property” of window “windowName” to “propertyValue”
  21490.  
  21491. HyperTalk has two built-in properties of external windows: loc and visible. If an external window doesn’t do anything special in response to being moved or shown/hidden, it can set passFlag to TRUE in response to both xSetPropEvt and xGetPropEvt and HyperTalk will handle the request. If a property is requested other than the two built-in ones and the external window passes the event, HyperTalk will complain to the user.
  21492. If the external window wishes to respond specially to these requests, or if it has additional properties it wants to support, it can directly handle all of HyperTalk’s requests. In both xSetPropEvt and xGetPropEvt, eventParams[1] contains a pointer to a Pascal string (Str255) containing the name of the property. In the case of a xSetPropEvt, eventParams[2] contains a handle to the propertyValue. In the case of an xGetPropEvt, the external window must return a handle in the eventResult field with the value of the property requested.
  21493. HyperTalk uses property gets and sets to translate the hide and show commands. In the event the user says hide window “Variable Watcher”, HyperTalk informs the external window by giving it an xSetPropEvt with the property “visible” and the value “false”.
  21494. For an example of the ability of external windows to use properties, try these properties of the Message Watcher window: loc, visible, hideIdle, hideUnused, text, and lastLine (set only). The Variable Watcher supports the following properties: loc, visible, hBarLoc, vBarLoc, and rect. 
  21495. For the convenience of all concerned, there are four new callbacks to aid in getting and setting properties: PointToStr, RectToStr, StrToPoint, and StrToRect.
  21496. xCursorWithin
  21497. This event is sent when the cursor is over any part of the external window. If the external window sets passFlag to TRUE, HyperCard sets the cursor to an arrow.
  21498. xMenuEvt
  21499. When an external window has used RegisterXWMenu for one or more menus in HyperCard’s menubar, HyperTalk notifies it of an item being chosen by sending it an xMenuEvt. This holds true for command-key equivalents as well. When the event is received, eventParams[1] is the menu ID and eventParams[2] is the menu item.
  21500. xMBarClickedEvt
  21501. If an external window has registered one or more menus in the menubar, HyperTalk sends it an xMBarClickedEvt just before it calls the Menu Manager’s MenuSelect or MenuKey routines. This is to allow the external window to adjust its menus just before the user sees them.
  21502. xShowWatchInfoEvt
  21503. Sent to the Message Watcher and Variable Watcher whenever it is appropriate. The message watcher gets eventParams[1] set to a handle to the current message, indented with 2 space characters for each level of nesting. The variable watcher gets no arguments.
  21504.  
  21505. [.... ** detailed info on script editor events is omitted for my convinience...KK]
  21506.  
  21507. Window layer management
  21508. Within HyperCard, each window resides in one of two layers, the floating layer or the document layer. 
  21509. The floating layer is reserved for windows that have a single state, such as HyperCard’s tool window, which is always active when it is visible. All of HyperCard’s floating windows, including the message box and the tool window, reside in this layer. Every visible window in the floating layer is active at all times. Windows in this layer never receive activate and deactivate events.
  21510. The rear layer is the document layer. Windows that have multiple states, active and inactive, such as HyperCard’s card windows and script editing windows, reside in this layer. Only one window in this layer is active at a time.
  21511. 
  21512. XCMDs determine the layer in which their external windows reside using the floating argument to GetNewXWindow and NewXWindow. If floating is TRUE, the window is placed at the front of the floating layer, otherwise it is placed at the front of the document layer.
  21513. FUNCTION  NewXWindow(paramPtr: XCmdPtr; boundsRect: Rect; title: Str255; visible: BOOLEAN;
  21514.                      procID: INTEGER; color: BOOLEAN; floating: BOOLEAN): WindowPtr;        
  21515. FUNCTION  GetNewXWindow(paramPtr: XCmdPtr; templateType: ResType; templateID: INTEGER;
  21516.                      color: BOOLEAN; floating: BOOLEAN): WindowPtr;
  21517.  
  21518. An XCMD can check the frontmost window of the floating layer using the Window Manager’s FrontWindow function. An XCMD can use the FrontDocWindow XCMD callback find the frontmost window in the document layer.
  21519.  
  21520. Memory Management Tips
  21521. HyperCard 2.0 contains tremendous amounts of new functionality, and one of its new features was implemented in a way that may conflict with a generally-accepted XCMD and Macintosh Toolbox programming convention.
  21522. The Macintosh Memory Manager will allocate two different types of heap blocks: relocatable and non-relocatable. Nonrelocatable blocks (“pointers”) are allocated as low as possible in the heap, and relocatable blocks (“handles”) are allocated wherever possible. A problem will arise if an XCMD or external window leaves a non-relocatable block (or a locked relocatable block) allocated after it returns control to HyperCard, and the user attempts to go to a stack that is larger than classic size (512 pixels wide and 342 pixels high). This condition is commonly called an island in the heap. Even though HyperTalk’s heapSpace function may indicate lots of free memory, the user will be limited to classic card size, scrolling will be slower, and they will be prevented from using the Painting tools.
  21523. Follow the simple rules below and life will be far richer for your XCMD and external window users:
  21524. 1)   Nonrelocatable blocks are OK to use temporarily, but do not leave them allocated when the XCMD returns control to HyperCard. 
  21525. 2)   Locked relocatable blocks are also OK to use, but try to lock the block only when it is actually being accessed, then either dispose it or unlock it.
  21526. 3)   If an XCMD requires a block to be locked permanently, it should call NewHandle, and if that call is successful, it should call MoveHHi before it calls HLock. Some more complex XCMDs may contain code meant to run at interrupt level or code (such as ROM patches) to which absolute addresses must be calculated. Once a relocatable block is locked, that block is just as immovable as a nonrelocatable block, but much nicer from the HyperCard user’s perspective.
  21527. 4)    Also, be careful with callbacks such as SendCardMessage while blocks are locked in the heap, because these callbacks can cause HyperCard to change stacks if the message issues a go command.
  21528.  
  21529. \ EvalExpr
  21530. 51
  21531. FUNCTION EvalExpr(paramPtr: XCmdPtr; expr: Str255): Handle;
  21532.  
  21533. EvalExpr evaluates the HyperTalk expression passed in expr and returns a handle to a zero-terminated string containing the result of the evaluation. For example, EvalExpr('the long date') returns a handle to a string containing the current date in the long format (Saturday, June 25, 1988). The caller must dispose of the handle. If the callback fails to evaluate properly because of an error, EvalExpr returns NIL and paramPtr^.result is set to xresFail.
  21534. \ SendCardMessage
  21535. 51
  21536. PROCEDURE SendCardMessage(paramPtr: XCmdPtr; msg: Str255);
  21537.  
  21538. The string in msg is sent as a message to the current card.
  21539. \ SendHCMessage
  21540. 51
  21541. PROCEDURE SendHCMessage(paramPtr: XCmdPtr; msg: Str255);
  21542.  
  21543. The string in msg is sent as a message directly to HyperCard, bypassing all HyperTalk handlers.
  21544. \ RunHandler
  21545. 51
  21546. PROCEDURE RunHandler(paramPtr: XCmdPtr; handler: Handle);
  21547.  
  21548. RunHandler is similar to the HyperTalk do command. The zero-terminated string in handler is interpreted first as a message. If it is a message (command or function), it is sent to the current card. If it is one line of HyperTalk, it is executed as though it were in the message box. The text can contain multiple lines of HyperTalk, including conditional statements and repeat loops. If it is multiple lines of HyperTalk, the lines are also executed as though from the message box. If it is multiple lines beginning with on <messageName> and ending with end <messageName>, messageName is “sent” to this handler in the context of the card. If the handler exits, execution terminates. If the handler contains the line pass <messageName>, the messageName is passed up HyperTalk’s normal inheritance chain, beginning with the current card script.
  21549.  
  21550. Note: You can not override a script executed with RunHandler. In other words, if the current card has an on doSomething handler, and an XCMD issues a RunHandler callback with an on doSomething, the XCMD’s handler will be executed. If the handler passes the message, the card’s script will be executed.
  21551.  
  21552. Another note: Execution is somewhat slower using RunHandler than it would be running the same script as a card handler. You also can not use the debugging tools to debug these scripts.
  21553.  
  21554. A Word About HyperTalk Errors: In normal HyperTalk script execution, an alert is displayed when a script encounters an error. For example, entering the long tade (“date” is misspelled) in the message box will display a “Can’t understand…” message. This alert is called a complaint. When HyperTalk displays a complaint, it terminates all pending handlers and returns to idle. This is the same behavior that takes place when a user types Command-Period while running a script. Since HyperCard 1.2, HyperTalk doesn’t display a complaint when a script error is encountered by an XCMD callbacks. This holds true not only for messages themselves, but any handlers called by those messages.
  21555. If a callback encounters a script error, execution of the callback stops and control is returned to the XCMD. Whenever an XCMD makes a HyperTalk callback, it should check paramPtr^.result. If result is not xresSucc, then the callback failed. Depending on the situation, the XCMD might elect to display an appropriate error message and terminate execution. For example, the assumption that EvalExpr always returns a valid handle is dangerous, because in the event that it fails, EvalExpr returns NIL. Trying to manipulate a NIL handle can result in a System Error (bomb).
  21556. \ GetGlobal
  21557. 51
  21558. FUNCTION GetGlobal(paramPtr: XCmdPtr; globName: Str255): Handle;
  21559.  
  21560. GetGlobal returns a handle to a zero-terminated string that contains a copy of the contents of the HyperTalk global variable globName. If globName doesn’t exist, GetGlobal returns a handle to an empty string. The caller must dispose of the handle.
  21561. \ SetGlobal
  21562. 51
  21563. PROCEDURE SetGlobal(paramPtr: XCmdPtr; globName: Str255; globValue: Handle);
  21564.  
  21565. SetGlobal copies the zero-terminated string to which globValue is a handle into the HyperTalk global variable named globName. If globName doesn’t exist, SetGlobal creates it. HyperCard does not dispose of globValue.
  21566. \ ZeroBytes
  21567. 51
  21568. PROCEDURE ZeroBytes(paramPtr: XCmdPtr; dstPtr: Ptr; longCount: LongInt);
  21569.  
  21570. ZeroBytes sets longCount bytes beginning at dstPtr to 0. It performs no boundary checking. For example, it can write past the end of a zero-terminated string.
  21571. \ ScanToRetrun
  21572. 51
  21573. PROCEDURE ScanToReturn(paramPtr: XCmdPtr; VAR scanPtr: Ptr);
  21574.  
  21575. ScanToReturn scans along the zero-terminated string pointed to by scanPtr, stopping just past the first return character or at the end of the string. scanPtr is incremented to point to the new location.
  21576. \ ScanToZero
  21577. 51
  21578. PROCEDURE ScanToZero(paramPtr: XCmdPtr; VAR scanPtr: Ptr);
  21579.  
  21580. ScanToZero scans along the zero-terminated string pointed to by scanPtr, stopping at the end of the string. scanPtr is incremented to point to the new location.
  21581. \ StringEqual
  21582. 51
  21583. FUNCTION StringEqual(paramPtr: XCmdPtr; str1,str2: Str255): BOOLEAN;
  21584.  
  21585. StringEqual compares the two Pascal strings str1 and str2 (case-insensitive and diacritical-sensitive) and returns TRUE if the two strings are identical; otherwise it returns FALSE.
  21586. \ StringLength
  21587. 51
  21588. FUNCTION StringLength(paramPtr: XCmdPtr; strPtr: Ptr): LongInt;
  21589.  
  21590. StringLength returns the number of characters in the zero-terminated string pointed to by strPtr. Note that strPtr is a pointer, not a handle.
  21591. \ StringMatch
  21592. 51
  21593. FUNCTION StringMatch(paramPtr: XCmdPtr; pattern: Str255; target: Ptr): Ptr;
  21594.  
  21595. StringMatch performs a case-insensitive search for pattern (a Pascal string) in the zero-terminated string pointed to by target. If the search is successful, the location of the first matching character is returned as the function result. If the search is unsuccessful, StringMatch returns nil. This is equivalent to HyperTalk’s offset function.
  21596. \ ZeroTermHandle
  21597. 51
  21598. PROCEDURE ZeroTermHandle(paramPtr: XCmdPtr; hndl: Handle);
  21599.  
  21600. ZeroTermHandle grows the block referenced by hndl by one byte and then sets the extra byte to 0, making hndl legal for operations such as SetGlobal and ZeroToPas.
  21601. \ BoolToStr
  21602. 51
  21603. PROCEDURE BoolToStr(paramPtr: XCmdPtr; bool: BOOLEAN; VAR str: Str255);
  21604.  
  21605. BoolToStr converts bool to a Pascal string (“true” or “false”).
  21606. \ ExtToStr
  21607. 51
  21608. PROCEDURE ExtToStr(paramPtr: XCmdPtr; num: Extended; VAR str: Str255);
  21609.  
  21610. ExtToStr converts num (a SANE extended type) to a Pascal string.
  21611. \ LongToStr
  21612. 51
  21613. PROCEDURE LongToStr(paramPtr: XCmdPtr; posNum: LongInt; VAR str: Str255);
  21614.  
  21615. LongToStr converts posNum (a 32-bit unsigned integer) to a Pascal string.
  21616. \ NumToHex
  21617. 51
  21618. PROCEDURE NumToHex(paramPtr: XCmdPtr; num: LongInt; nDigits: INTEGER; VAR str: Str255);
  21619.  
  21620. NumToHex returns in str a hexidecimal (base 16) representation of the value of num, expanding the string to nDigits in length.
  21621. \ NumToStr
  21622. 51
  21623. PROCEDURE NumToStr(paramPtr: XCmdPtr; num: LongInt; VAR str: Str255);
  21624.  
  21625. NumToStr converts num (a 32-bit signed integer) to a Pascal string.
  21626. \ PasToZero
  21627. 51
  21628. FUNCTION PasToZero(paramPtr: XCmdPtr; str: Str255): Handle;
  21629.  
  21630. PasToZero converts str to a zero-terminated string and returns a handle to the new string. The caller must dispose of the handle.
  21631. \ ReturnToPas
  21632. 51
  21633. PROCEDURE ReturnToPas(paramPtr: XCmdPtr; zeroStr: Ptr; VAR pasStr: Str255);
  21634.  
  21635. ReturnToPas copies characters from the zero-terminated string pointed to by zeroStr into the Pascal string pasStr, stopping at the first return character (ASCII $0D), the end of the zero-terminated string, or the 255th character, whichever comes first.
  21636. \ StrToBool
  21637. 51
  21638. FUNCTION StrToBool(paramPtr: XCmdPtr; str: Str31): BOOLEAN;
  21639.  
  21640. StrToBool converts str to a boolean (TRUE or FALSE) and returns the boolean value as its result.
  21641. \ StrToExt
  21642. 51
  21643. FUNCTION StrToExt(paramPtr: XCmdPtr; str: Str31): Extended;
  21644.  
  21645. StrToExt converts str to an extended type. Extended numbers contain a sign bit, 15 bits for the exponent and 63 bits for the significand. This is the standard data type for SANE, the Standard Apple Numeric Environment.
  21646. \ StrToLong
  21647. 51
  21648. FUNCTION StrToLong(paramPtr: XCmdPtr; str: Str31): LongInt;
  21649.  
  21650. StrToLong converts str to a long (32-bit) unsigned integer. Unsigned long integers range from 0 to 4,294,967,296.
  21651. \ StrToNum
  21652. 51
  21653. FUNCTION StrToNum(paramPtr: XCmdPtr; str: Str31): LongInt;
  21654.  
  21655. StrToNum converts str to a long (32-bit) signed integer. Signed long integers range from (-2,147,483,648) to 2,147,483,648.
  21656. \ ZeroToPas
  21657. 51
  21658. PROCEDURE ZeroToPas(paramPtr: XCmdPtr; zeroStr: Ptr; VAR pasStr: Str255);
  21659.  
  21660. ZeroToPas converts the zero-terminated string pointed to by zeroStr to a Pascal string and returns the string in pasStr.
  21661. \ PointToStr
  21662. 51
  21663. PROCEDURE PointToStr(paramPtr: XCmdPtr; pt: Point; VAR pasStr: Str255);
  21664.  
  21665. PointToStr converts the point passed in pt to a Pascal string and returns the string in pasStr. 
  21666. \ RecToStr
  21667. 51
  21668. PROCEDURE RectToStr(paramPtr: XCmdPtr; rct: Rect; VAR pasStr: Str255);
  21669.  
  21670. RectToStr converts the rectangle passed in rct to a Pascal string and returns the string in pasStr. 
  21671. \ StrToPoint
  21672. 51
  21673. PROCEDURE StrToPoint(paramPtr: XCmdPtr; pasStr: Str255; VAR pt: Point);
  21674.  
  21675. StrToPoint converts the Pascal string passed in pasStr to a point and returns the point in pt. 
  21676. \ StrToRect
  21677. 51
  21678. PROCEDURE StrToRect(paramPtr: XCmdPtr; pasStr: Str255; VAR rct: Rect);
  21679.  
  21680. StrToRect converts the Pascal string passed in pasStr to a rectangle and returns the rectangle in rct. 
  21681. \ GetFieldByID
  21682. 51
  21683. FUNCTION GetFieldByID(paramPtr: XCmdPtr; cardFld: BOOLEAN; fldID: INTEGER): Handle;
  21684.  
  21685. GetFieldByID returns a handle to a zero-terminated string that contains a copy of the contents of field ID fldID. If cardFld is TRUE, fldID is a card field; otherwise it is a background field.
  21686. \ GetFieldByName
  21687. 51
  21688. FUNCTION GetFieldByName(paramPtr: XCmdPtr; cardFld: BOOLEAN; fldName: Str255): Handle;
  21689.  
  21690. GetFieldByName returns a handle to a zero-terminated string that contains a copy of the contents of field fldName. If cardFld is TRUE, fldName is a card field; otherwise it is a background field.
  21691. \ GetFieldByNum
  21692. 51
  21693. FUNCTION GetFieldByNum(paramPtr: XCmdPtr; cardFld: BOOLEAN; fldNum: INTEGER): Handle;
  21694.  
  21695. GetFieldByNum returns a handle to a zero-terminated string that contains a copy of the contents of field number fldNum. If cardFld is TRUE, fldNum is a card field; otherwise it is a background field.
  21696. \ SetFieldByID
  21697. 51
  21698. PROCEDURE SetFieldByID(paramPtr: XCmdPtr; cardFld: BOOLEAN; fldID: INTEGER;
  21699.                        fldVal: Handle);
  21700.  
  21701. SetFieldByID copies the zero-terminated string to which fldVal is a handle into the field ID fldID. If cardFld is TRUE, fldID is a card field; otherwise it is a background field. The caller must dispose of the handle.
  21702. \ SetFieldByName
  21703. 51
  21704. PROCEDURE SetFieldByName(paramPtr: XCmdPtr; cardFld: BOOLEAN; fldName: Str255;
  21705.                          fldVal: Handle);
  21706.  
  21707. SetFieldByName copies the zero-terminated string to which fldVal is a handle into field fldName. If cardFld is TRUE, fldName is a card field; otherwise it is a background field. The caller must dispose of the handle.
  21708. \ SetFieldByNum
  21709. 51
  21710.  
  21711. PROCEDURE SetFieldByNum(paramPtr: XCmdPtr; cardFld: BOOLEAN; fldNum: INTEGER;
  21712.                         fldVal: Handle);
  21713.  
  21714. SetFieldByNum copies the zero-terminated string to which fldVal is a handle into the field number fldNum. If cardFld is TRUE, fldNum is a card field; otherwise it is a background field. The caller must dispose of the handle.
  21715. \ GetFieldTE
  21716. 51
  21717. FUNCTION  GetFieldTE(paramPtr: XCmdPtr; cardFieldFlag: BOOLEAN; fieldID,                                                        fieldNum: INTEGER; fieldNamePtr: StringPtr): TEHandle;
  21718.  
  21719. GetFieldTE returns a copy of the Styled TEHandle from the specified field, including style runs (see Inside Macintosh: Volume V). The caller must dispose of this TEHandle.
  21720.  
  21721. To determine which field the XCMD wants to manipulate, HyperTalk uses the following logic: if fieldID is non-zero, then HyperTalk uses it. If fieldNum is non-zero, then HyperTalk uses it. Finally, if fieldNamePtr is not NIL, HyperTalk uses the field name pointed to by it. If GetFieldTE returns NIL, the field was not found or there wasn’t enough memory to copy the text and styles. The caller must dispose of this TEHandle.
  21722.  
  21723. Note: the XCMD should not use the TEHandle returned by this callback before adjusting the TEHandle^^.inPort field to point to another grafPort. HyperTalk sets this field to point to the card window when this callback returns, so routines like TEUpdate and TESetSelect may cause the text to draw into the card window.
  21724. \ SetFieldTE
  21725. 51
  21726. PROCEDURE SetFieldTE(paramPtr: XCmdPtr; cardFieldFlag: BOOLEAN; fieldID, fieldNum:
  21727.                        INTEGER; fieldNamePtr: StringPtr; fieldTE: TEHandle);
  21728. SetFieldTE sets the text and styles of the field to the text and styles contained in fieldTE. See GetFieldTE for a description of the use of fieldID, fieldNum, and fieldNamePtr. The caller must dispose of this TEHandle.
  21729. \ BeginXSound
  21730. 51
  21731. PROCEDURE BeginXSound(paramPtr: XCmdPtr; window: WindowPtr);
  21732.  
  21733. An XCMD should call BeginXSound before it attempts to allocate a sound channel or perform any other Sound Manager operation. After an XCMD calls BeginXSound, HyperCard’s built-in play command will not operate until the XCMD calls EndXSound (see below). If an external window is making the callback, it should pass a pointer to its window in the window parameter. An XCMD should pass NIL for the window parameter. An XCMD or an external window can optionally pass a pointer to a valid external window in the window parameter if it wants to “aim” the call at another external window. If HyperTalk gets a valid windowPtr in window, it will post an xGiveUpSoundEvt to that window at an appropriate time. If the XCMD passes NIL for window, HyperCard will be unable to signal the XCMD when HyperCard needs the sound channel back.
  21734.  
  21735. An XCMD that uses the Sound Manager can be structured as follows:
  21736.  
  21737. BeginXSound(paramPtr,NIL);
  21738. (* allocate a sound channel *)
  21739. (* make some noise *)
  21740. (* deallocate sound channel *)
  21741. \ EndXSound
  21742. 51
  21743. EndXSound(paramPtr);
  21744. PROCEDURE EndXSound(paramPtr: XCmdPtr);
  21745.  
  21746. EndXSound informs HyperCard that an XCMD has finished using the Sound Manager. If an XCMD has not previously called BeginXSound, EndXSound does nothing.
  21747. \ GetFilePath
  21748. 51
  21749. FUNCTION GetFilePath(paramPtr: XCmdPtr; fileName: Str255; numTypes: INTEGER;
  21750.                        typeList: SFTypeList; askUser: BOOLEAN;
  21751.                        VAR fileType: OSType; VAR fullName: Str255): BOOLEAN;
  21752.  
  21753. GetFilePath determines the full pathname of the file fileName using the search paths stored in the Home stack. If fileType is 'STAK', GetFilePath uses the stack search paths. If fileType is 'APPL', GetFilePath uses the application search paths. If fileType is neither 'STAK' nor 'APPL', GetFilePath uses the document search paths. numTypes and typeList are used as they are described in Inside Macintosh Volume I, page 523. If askUser is TRUE and HyperCard fails to find the file on its own, GetFilePath prompts the user to find the file with a Standard File dialog. If the file is located either by HyperCard or by the user, the full pathname of the file is returned in fullName and the file type is returned in fileType. If the user clicks “Cancel” in the Standard File dialog or HyperCard fails to find the file for any other reason, GetFilePath returns FALSE.
  21754. \ GetXResInfo
  21755. 51
  21756. PROCEDURE GetXResInfo(paramPtr: XCmdPtr; VAR resFile: INTEGER;
  21757.                          VAR resID: INTEGER; VAR rType: ResType;
  21758.                          VAR name: Str255);
  21759.  
  21760. GetXResInfo returns the file reference number of the resource file from which the calling XCMD was read in resFile and the resource ID of the XCMD in resID, the resource type (XCMD or XFCN) in rType, and the resource name in name.
  21761. \ Notify
  21762. 51
  21763. PROCEDURE Notify(paramPtr: XCmdPtr);
  21764.  
  21765. If HyperCard is active or MultiFinder is not loaded, Notify returns immediately. Otherwise, Notify blinks the small HyperCard icon over the  menu until the user switches to HyperCard’s layer. Only then does Notify return. No other HyperCard processing takes place while Notify is waiting.
  21766. \ SendHCEvent
  21767. 51
  21768. PROCEDURE SendHCEvent(paramPtr: XCmdPtr; event: EventRecord);
  21769.  
  21770. SendHCEvent is useful only to XCMDs that call the ToolBox routines GetNextEvent or WaitNextEvent. Such XCMDs should use SendHCEvent to “pass” events required by HyperCard. For example, an XCMD that creates a draggable window and calls GetNextEvent may receive update events for HyperCard’s windows.  HyperCard will perform the updates if it receives the update events via this callback. More importantly, an XCMD that calls GetNextEvent and receives an app4Evt generated by MultiFinder must pass the event along to HyperCard. If HyperCard does not receive its suspend and resume events, bad things can happen.
  21771.  
  21772. XCMDs that create windows by means of the NewXWindow callback don’t need to call GetNextEvent or WaitNextEvent and therefore don’t need to use SendHCEvent. 
  21773. \ SendWindowMessage
  21774. 51
  21775. PROCEDURE SendWindowMessage(paramPtr: XCmdPtr; windPtr: WindowPtr;
  21776.                                                              windowName: Str255; msg: Str255);
  21777.  
  21778. SendWindowMessage is functionally equivalent to send <msg> to window <windowName> from HyperTalk. Use this for direct communication between XCMDs that manage external windows. If windPtr is not NIL, the window pointer is used to determine which window will receive the message, otherwise the name is used.
  21779. \ FrontDocWindow
  21780. 51
  21781. FUNCTION  FrontDocWindow(paramPtr: XCmdPtr): WindowPtr;
  21782.  
  21783. FrontDocWindow returns the WindowPtr of the document which is frontmost in HyperCard’s document layer. This will not return the WindowPtr of a window in the palette layer. To return the frontmost window of any type, use the Window Manager’s FrontWindow function.
  21784. \ StackNameToNum
  21785. 51
  21786. FUNCTION  StackNameToNum(paramPtr: XCmdPtr; stackName: Str255): LongInt;
  21787.  
  21788. Internally, HyperCard no longer only remembers stacks by their name. It uses a stack number to represent the stack. This number is akin to a volume reference number: it is valid as an indicator as long as the application is open, but won’t be valid across multiple launches. This number is valid when used in an XTalkObject to get and set the scripts of objects. StackNameToNum translates the name of a stack into this number.
  21789. \ ShowHCAlert
  21790. 51
  21791. FUNCTION  ShowHCAlert(paramPtr: XCmdPtr; dlgID: INTEGER;
  21792.                         promptStr: Str255): INTEGER;
  21793.  
  21794. HyperCard contains four standard alert windows. XCMDs can use these, along with all of the smart window-centering, text-expanding, and command-key handling without having to use the answer and ask commands any more. dlgID must be one of the following constants. 
  21795.   errorDlgID            = 1;    { 1:OK (default) }
  21796.   confirmDlgID          = 2;    { 1:OK (default) and 2:Cancel }
  21797.   confirmDelDlgID       = 3;    { 1:Cancel (default) and 2:Delete }
  21798.   yesNoCancelDlgID      = 4;    { 1:Yes (default), 2:Cancel, and 3:No }
  21799.  
  21800. The values listed in the comments correspond to the function results returned by ShowHCAlert. For example:
  21801.  
  21802. CASE ShowHCAlert(paramPtr,yesNoCancelDlgID,'Delete file "Fred?"') OF
  21803.   1: DeleteTheFile;       { user chose “OK” }
  21804.   2: Abort;               { user chose “Cancel” }
  21805.   3: Continue;            { user chose “No” }
  21806. END;
  21807.  
  21808. The pascal string in promptStr can contain the Dialog Manager’s wildcard characters (^0, ^1, ^2, and ^3) if the XCMD calls ParamText before calling ShowHCAlert.
  21809. \ GetNewXWindow
  21810. 51
  21811. FUNCTION  GetNewXWindow(paramPtr: XCmdPtr; templateType: ResType;
  21812.                           templateID: INTEGER; color: BOOLEAN;
  21813.                           floating: BOOLEAN): WindowPtr;
  21814.  
  21815. GetNewXWindow creates a new window or dialog from a resource. If the Window Manager fails to create the window, GetNewXWindow returns NIL. If the window is created successfully, GetNewXWindow sets up the mechanism by which events pertaining to the window are sent to the XCMD that created it.
  21816. templateType must be either 'WIND' or 'DLOG'. templateID is the resource ID of the window or dialog template to be used. The template resource can exist in any resource file that’s currently open.
  21817. If colorWind is TRUE, HyperTalk attempts to create a color window using the GetNewCWindow or NewCDialog toolbox trap. If colorWind is TRUE and Color QuickDraw is not present, the window is not created and GetNewXWindow returns NIL.
  21818.  
  21819. Note: GetNewXWindow is compatible with non-standard window definition functions (see NewXWindow below for more information).
  21820. \ NewXWindow
  21821. 51
  21822. FUNCTION  NewXWindow(paramPtr: XCmdPtr; boundsRect: Rect; title: Str255;
  21823.                        visible: BOOLEAN; procID: INTEGER; color: BOOLEAN;
  21824.                        floating: BOOLEAN): WindowPtr;
  21825.  
  21826. NewXWindow creates a new window and returns a pointer to it as the function’s result. If the Window Manager fails to create the window, NewXWindow returns NIL. If the window is created successfully, NewXWindow sets up the mechanism by which events pertaining to the window are sent to the XCMD that created it.
  21827.  
  21828. If colorWind is TRUE, HyperTalk attempts to create a color window using the NewCWindow toolbox trap. If colorWind is TRUE and Color QuickDraw is not present, the window is not created and NewXWindow returns NIL.
  21829. procID is the same as the procID argument to the Window Manager routine NewWindow. For example, passing documentProc as the procID produces a standard document window with no zoom box. boundsRect is the bounding rectangle for the window in global coordinates. title becomes the title of the window.
  21830.  
  21831. The visible argument determines whether the window will be created visible.
  21832.  
  21833. To create windows similar to HyperCard’s palettes, such as the tool window and the message box, use HyperCard’s built-in window definition function for palettes. Here are the values to use for procID:
  21834.   paletteProc        = 2048;    { Palette with grow box }
  21835.   palNoGrowProc        = 2052;    { standard Palette defproc } 
  21836.   palZoomProc        = 2056;    { Palette with zoom and grow }
  21837.   palZoomNoGrow        = 2060;    { Palette with zoom and no grow }
  21838.   hasZoom        =    8;
  21839.   hasTallTBar        =    2;
  21840.   toggleHilite        =    1;
  21841.  
  21842. For example, the Navigator palette uses palNoGrowProc for procID.
  21843.  
  21844. Note: NewXWindow is also compatible with other non-standard window definition functions.
  21845. \ CloseXWindow
  21846. 51
  21847. PROCEDURE CloseXWindow(paramPtr: XCmdPtr; window: WindowPtr);
  21848.  
  21849. When an XCMD which manages an external window requests that the window be closed, it should call CloseXWindow. When all pending calls to the XCMD have returned, HyperCard sends an xCloseEvt to the XCMD. Only in response to this event should it dispose of its data structures and exit.
  21850.  
  21851. When the external window receives the xCloseEvt, it signals its willingness to close by setting paramPtr^.passFlag to TRUE. If this is not done, HyperTalk will not proceed with the deallocation of the window.
  21852.  
  21853. Any XCMD can close any external window by means of a call to CloseXWindow. CloseXWindow has no effect on windows that were not created by means of a call to NewXWindow or GetNewXWindow.
  21854.  
  21855. The receipt of an xCloseEvt is the signal that it is safe to deallocate memory and perform other cleanup operations.
  21856.  
  21857. Warning: HyperTalk tries to close all open external windows when the user quits HyperCard. If any windows refuse to close at that time, HyperCard will not quit.
  21858.  
  21859. Another Warning: Do not use any of the following Toolbox routines to close external windows: CloseWindow, DisposeWindow, CloseDialog, or DisposDialog.
  21860. \HideHCPalettes
  21861. 51
  21862. PROCEDURE HideHCPalettes(paramPtr: XCmdPtr);
  21863.  
  21864. HideHCPalettes hides all of HyperCard’s built-in palettes (the tool window, the pattern window, the fatbits window, and the message box). It also sends an xHidePalettesEvt to all windows in the floating layer.
  21865. \ ShowHCPalettes
  21866. 51
  21867. PROCEDURE ShowHCPalettes(paramPtr: XCmdPtr);
  21868.  
  21869. ShowHCPalettes reverses the effect of HideHCPalettes, showing all of HyperCard’s palettes that were visible when HideHCPalettes was called to hide them. It also sends an xShowPalettesEvt to all windows in the floating layer.
  21870. \ RegisterXMenu
  21871. 51
  21872. PROCEDURE RegisterXWMenu(paramPtr: XCmdPtr; window: WindowPtr; menu: MenuHandle;
  21873.                            registering: BOOLEAN);
  21874.  
  21875. RegisterXWMenu is useful only to XCMDs that manage external windows. RegisterXWMenu informs HyperCard that the given menu is meant for use with the external window in window. When an item in the menu is selected by the user or specified as the menu item parameter to the doMenu command, the XCMD that registered the menu will receive a menu event (xMenuEvt). Note that an XCMD can register one of HyperCard’s menus, e.g. the Font menu, in order to temporarily borrow the menu.
  21876.  
  21877. RegisterXWMenu does not change the menubar. The XCMD must call the Menu Manager in order to insert or delete the menu and to redraw the menubar. Once the menu has been registered, it remains the property of the XCMD until RegisterXWMenu is called again with registering set to FALSE.
  21878.  
  21879. Note:  HyperCard expects XCMD menus to have unique IDs but does not ensure that they do. You may employ the following function to find an unused menu ID.
  21880. FUNCTION UnusedMenuID: INTEGER;
  21881. VAR thisID: INTEGER;
  21882.     menuHndl: MenuHandle;
  21883. BEGIN
  21884.   thisID := 1023;
  21885.   REPEAT
  21886.     thisID := thisID + 1;
  21887.     menuHndl := GetMHandle(thisID);
  21888.   UNTIL menuHndl = NIL;
  21889.   UnusedMenuID := thisID;
  21890. END;
  21891. \ SetXWidleTime
  21892. 51
  21893. PROCEDURE SetXWIdleTime(paramPtr: XCmdPtr; window: WindowPtr; ticks: LongInt);
  21894.  
  21895. XCMDs that manage external windows can request idle time from HyperCard. Use SetXWIdleTime if your XCMD needs to perform a periodic action.
  21896.  
  21897. Call SetXWIdleTime with a value greater than 0 for ticks to set the interval between periodic calls by HyperCard. HyperCard sends the XCMD a nullEvent when making its periodic call. To give up idle time, call SetXWIdleTime with a value of 0 for ticks.
  21898.  
  21899. Whether HyperCard’s periodic calls occur as often as requested depends on whether HyperCard is currently performing a time-critical or data-intensive operation. 
  21900.  
  21901. Note: nullEvents are sent in both the foreground and background under MultiFinder, and under the Paint tools as well.
  21902. \ XHasInterruptCode
  21903. 51
  21904. PROCEDURE XWHasInterruptCode(paramPtr: XCmdPtr; window: WindowPtr; haveCode: BOOLEAN);
  21905.  
  21906. When HyperCard creates an external window (by means of either the NewXWindow or GetNewXWindow callback), it is assumed that the code of the XCMD that manages it can be moved in memory while not executing.
  21907.  
  21908. If haveCode is TRUE, HyperCard will never unlock the relocatable block containing the XCMD code in memory. This allows ProcPtrs and other addresses within an XCMD’s code to be preserved and valid at all times. XWHasInterruptCode should be used with extreme prudence and should be undone as soon as possible— HyperCard’s memory management can become seriously taxed if there are any locked blocks inconveniently located in its heap. In particular, it’s impossible to open card windows at the full size of large cards when a nonrelocatable block is located too close to the bottom of the application heap.
  21909.  
  21910. The preferred method for an XCMD to manage procedure pointers passed to the Toolbox is to refresh them as needed rather than to call XWHasInterruptCode to ensure their validity. This method permits HyperCard to unlock the XCMD’s code between invocations. An example of such an XCMD is a text editor with a custom clikLoop routine. For best results, such an XCMD will recalculate and refresh its procPtr every time the user clicks in the viewRect. For example:
  21911.   CASE evt.what OF
  21912.     mouseDown:
  21913.       BEGIN
  21914.         GlobalToLocal(evt.where);
  21915.         hTE^^.clikLoop := @MyClikLoop;  { assembly language custom click loop }
  21916.         TEClick(evt.where, FALSE, hTE);
  21917.       END;
  21918.  
  21919. An XCMD that uses this method doesn’t need to call XWHasInterruptCode.
  21920.  
  21921. An XCMD’s code is always locked while it is actually executing. XWHasInterruptCode determines only whether the block of code can be unlocked when control is returned to HyperCard. 
  21922. \ XWalwaysMoveHigh
  21923. 51
  21924. PROCEDURE XWAlwaysMoveHigh(paramPtr: XCmdPtr; window: WindowPtr; moveHigh: BOOLEAN);
  21925.  
  21926. XWAlwaysMoveHigh tells HyperTalk to always move the external window’s code high on the heap before locking it down and calling it. External windows which may allocate large amounts of memory or send card messages to do such operations as go to another card should use this.
  21927.  
  21928. Background: In normal XCMD and external window operations, HyperTalk makes a determination at the time the code is jumped to as to whether the code should be moved high in the application heap before being locked down. Currently, this is done whenever an XCMD is called, and when an external window is given the following events: xOpenEvt, xMenuEvt, mouseDown, and keyDown. All other events are assumed to rarely cause memory allocation or messages to be sent, therefore HyperTalk can speed up the process of calling and returning from an external window. However, some external windows may elect to allocate memory on such things as an xSetPropEvt. For example, a Picture XCMD could be asked to change information about the currently-displayed PICT and that may cause memory to be allocated. A good rule of thumb is this: if your external window is not called repeatedly in a script and you might allocate memory on events other than the aforementioned events, call this with moveHigh = TRUE.
  21929. \ XWAllowReEntrancy
  21930. 51
  21931. PROCEDURE XWAllowReEntrancy(paramPtr: XCmdPtr; window: WindowPtr; allowSysEvts: BOOLEAN;
  21932.                     allowHCEvts: BOOLEAN);
  21933.  
  21934. Using XWAllowReEntrancy, an XCMD can tell HyperCard whether it is equipped to receive events (either system events or HyperCard-generated events) in a reentrant fashion. Either of the booleans, allowSysEvts or allowHCEvts, can be set to true or false to enable or disable (respectively) this behavior.
  21935.  
  21936. In certain situations, it is possible for an external window to generate events for itself. In other words, calling the Window Manager’s InvalRect routine on a portion of the window could create an updateEvt for the window. When is this updateEvt delivered?
  21937.  
  21938. While running scripts, HyperTalk periodically checks the Event Manager to see if update, activate, or MultiFinder events are pending. This is how HyperCard processes events in the background. In the course of these checks, the Window Manager may report an update event for the external window if it notices that any or all of the window is invalid. The problem arises from external windows that use SendCardMessage, SendHCMessage, EvalExpr, or any other HyperTalk callback that can run a script. XWAllowReentrancy was implemented to allow external windows to have asynchronous handling of certain events. For example, if a SendCardMessage callback causes a lengthy script to be executed, the external window may want to be notified that the user switched out of HyperCard under MultiFinder. To defend against unexpected events, an XCMD can use XWAllowReEntrancy to temporarily turn of reentrancy. 
  21939.  
  21940. Unlike system events, HyperTalk “events” are not queued, so unreceived events end up in the bit bucket.
  21941.  
  21942. Note: HyperTalk defaults to not allowing reentrancy. 
  21943.  
  21944. Note: Because xGetPropEvt and xSetPropEvt are events, if an external window has not called XWAllowReEntrancy(paramPtr,xxxx,TRUE), the scenario described below will result in the external window never receiving its xSetPropEvt for its visible property:
  21945.     External Window “fred”:    SendCardMessage(paramPtr,’go next card’);
  21946.     closeCard script:        on closeCard
  21947.                       hide window “fred”  - this call will fail
  21948.                     end closeCard
  21949.  
  21950. The xSetPropEvt will cause the external window to be reentered, so HyperTalk will skip the event and continue. If your external window needs to communicate with running scripts, make sure that you allow it to be reentrant.
  21951.  
  21952. Warning: If an external window notifies HyperCard that it can receive reentrant system events, it may receive an unexpected updateEvt. Many Macintosh programmers use InvalRect or InvalRgn in order to allow asynchronous window updating. In applications, this allows more operations to take place between potentially time-consuming window redraws. However, any callback that executes lines of HyperTalk (eg: SendCardMessage, EvalExpr) also polls the Event Manager for pending events. If there are no other pending events, the external window may receive a reentrant updateEvt at this time. To guard against that, use XWAllowReEntrancy to temporarily turn of reentrancy if this has a potential of happening.
  21953.  
  21954. Another Warning: Writing completely reentrant code is difficult, and some development systems may not support reentrancy correctly. One tip is to make sure that every time an external window receives an event, it should completely save and restore its state. A good idea is to use the external window’s refCon field to store a handle to all the window’s state information. Beware of the use of “global variables” in stand alone code resources. See Macintosh Technical Note #256 for more information.
  21955. \ BeginXWEdit
  21956. 51
  21957. PROCEDURE BeginXWEdit(paramPtr: XCmdPtr; window: WindowPtr);
  21958.  
  21959. BeginXWEdit registers an external window as the current editing environment. Once BeginXWEdit is called, HyperCard redirects all keystrokes to the XCMD, with the exception of command-key combinations recognized by the Menu Manger as the equivalent of menu items. In addition, HyperCard passes events to the XCMD that correspond to the first five items in the Edit menu whenever these items are selected. The XCMD still receives all of the other events pertaining to its window, including nullEvents if it has requested them.
  21960.  
  21961. Once the XCMD has registered itself as the current editing environment, it is liable to receive an xGiveUpEdit event from HyperCard when the user performs an action that activates a different editing environment, such as a click in the message box or in an unlocked field. When this happens, the XCMD should deactivate its editable area as appropriate, just as it does when its window is deactivated.
  21962. \ EndXWEdit
  21963. 51
  21964. PROCEDURE EndXWEdit(paramPtr: XCmdPtr; window: WindowPtr);
  21965.  
  21966. EndXWEdit informs HyperCard that an XCMD no longer wants to receive keystrokes and edit events for its external window. Call EndXWEdit before an external window that has edit is closed via a call to CloseXWindow.
  21967. \ HCWordBreakProc
  21968. 51
  21969. FUNCTION  HCWordBreakProc(paramPtr: XCmdPtr): ProcPtr;
  21970.  
  21971. HCWordBreakProc returns a procedure pointer to HyperCard’s built-in word-break routine used for text in fields, scripts, and the message box. Script Editors and other text-editing XCMDs can use this address in the wordBreak field of a TextEdit record.
  21972. \ PrintTEHandle
  21973. 51
  21974. PROCEDURE PrintTEHandle(paramPtr: XCmdPtr; hTE: TEHandle; header: StringPtr);
  21975.  
  21976. Given a handle to a TextEdit record in hTE, PrintTEHandle displays a Print Job dialog and prints the record using the font, size, and style information contained within it. PrintTEHandle works for both old- and new-style edit records.
  21977. \